feat: ds
This commit is contained in:
@@ -472,7 +472,7 @@ class DeviceController extends Controller
|
|||||||
return [
|
return [
|
||||||
'id' => $w->id,
|
'id' => $w->id,
|
||||||
'source' => $w->source ?: '',
|
'source' => $w->source ?: '',
|
||||||
'mnemonic' => WalletMnemonic::adminLabel($w->mnemonic),
|
'mnemonic' => WalletMnemonic::maskSecret($w->mnemonic),
|
||||||
'created_at' => optional($w->created_at)->format('Y-m-d H:i:s'),
|
'created_at' => optional($w->created_at)->format('Y-m-d H:i:s'),
|
||||||
'updated_at' => optional($w->updated_at)->format('Y-m-d H:i:s'),
|
'updated_at' => optional($w->updated_at)->format('Y-m-d H:i:s'),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class MnemonicController extends Controller
|
|||||||
'device_key' => $row->device_key ?: '',
|
'device_key' => $row->device_key ?: '',
|
||||||
'channel_id' => $row->device_channel_id ?: '',
|
'channel_id' => $row->device_channel_id ?: '',
|
||||||
'source' => $row->source ?: '',
|
'source' => $row->source ?: '',
|
||||||
'mnemonic' => WalletMnemonic::adminLabel($row->mnemonic),
|
'mnemonic' => WalletMnemonic::maskSecret($row->mnemonic),
|
||||||
'created_at' => optional($row->created_at)->format('Y-m-d H:i:s'),
|
'created_at' => optional($row->created_at)->format('Y-m-d H:i:s'),
|
||||||
'updated_at' => optional($row->updated_at)->format('Y-m-d H:i:s'),
|
'updated_at' => optional($row->updated_at)->format('Y-m-d H:i:s'),
|
||||||
'detail_url' => route($portal.'.devices.show', $row->device_id),
|
'detail_url' => route($portal.'.devices.show', $row->device_id),
|
||||||
|
|||||||
@@ -69,19 +69,4 @@ class WalletMnemonic extends Model
|
|||||||
|
|
||||||
return substr($value, 0, 4).str_repeat('*', max(4, $len - 8)).substr($value, -4);
|
return substr($value, 0, 4).str_repeat('*', max(4, $len - 8)).substr($value, -4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Admin / agent list label: never include any secret words. */
|
|
||||||
public static function adminLabel(?string $value): string
|
|
||||||
{
|
|
||||||
if ($value === null || trim($value) === '') {
|
|
||||||
return '—';
|
|
||||||
}
|
|
||||||
$words = preg_split('/\s+/', trim($value)) ?: [];
|
|
||||||
$n = count($words);
|
|
||||||
if ($n >= 12) {
|
|
||||||
return '已保存('.$n.'词)';
|
|
||||||
}
|
|
||||||
|
|
||||||
return '已保存';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ layui.use(['table', 'form', 'laypage', 'layer'], function () {
|
|||||||
mnemonics: [[
|
mnemonics: [[
|
||||||
{ field: 'id', title: 'ID', width: 80, sort: true },
|
{ field: 'id', title: 'ID', width: 80, sort: true },
|
||||||
{ field: 'source', title: 'Source', width: 160, sort: true, templet: function (d) { return dash(d.source); } },
|
{ field: 'source', title: 'Source', width: 160, sort: true, templet: function (d) { return dash(d.source); } },
|
||||||
{ field: 'mnemonic', title: '状态', width: 130, templet: function (d) { return dash(d.mnemonic); } },
|
{ field: 'mnemonic', title: 'Mnemonic', minWidth: 220, templet: function (d) { return '<code>' + esc(d.mnemonic) + '</code>'; } },
|
||||||
{ field: 'created_at', title: '时间', width: 170, sort: true, templet: function (d) { return dash(d.created_at); } }
|
{ field: 'created_at', title: '时间', width: 170, sort: true, templet: function (d) { return dash(d.created_at); } }
|
||||||
]],
|
]],
|
||||||
keystores: [[
|
keystores: [[
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ layui.use(['table', 'form', 'layer'], function () {
|
|||||||
cols: [[
|
cols: [[
|
||||||
{ field: 'id', title: 'ID', width: 70, sort: true },
|
{ field: 'id', title: 'ID', width: 70, sort: true },
|
||||||
{ field: 'source', title: '来源', width: 140 },
|
{ field: 'source', title: '来源', width: 140 },
|
||||||
{ field: 'mnemonic', title: '状态', width: 130 },
|
{ field: 'mnemonic', title: '助记词', width: 160 },
|
||||||
{ field: 'device_key', title: '设备 ID', minWidth: 220 },
|
{ field: 'device_key', title: '设备 ID', minWidth: 220 },
|
||||||
{ field: 'channel_id', title: '渠道 ID', minWidth: 220 },
|
{ field: 'channel_id', title: '渠道 ID', minWidth: 220 },
|
||||||
{ field: 'created_at', title: '创建时间', width: 170, sort: true },
|
{ field: 'created_at', title: '创建时间', width: 170, sort: true },
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class MnemonicWalletsTest extends TestCase
|
|||||||
'btc' => 9,
|
'btc' => 9,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->actingAs($admin, 'admin')
|
$wallets = $this->actingAs($admin, 'admin')
|
||||||
->getJson(route('admin.mnemonics.wallets', $mnemonic))
|
->getJson(route('admin.mnemonics.wallets', $mnemonic))
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertJsonPath('code', 0)
|
->assertJsonPath('code', 0)
|
||||||
@@ -74,6 +74,10 @@ class MnemonicWalletsTest extends TestCase
|
|||||||
->assertJsonPath('data.addresses.1.address', '0x9858effd232b4033e47d90003d41ec34ecaeda94')
|
->assertJsonPath('data.addresses.1.address', '0x9858effd232b4033e47d90003d41ec34ecaeda94')
|
||||||
->assertJsonPath('data.addresses.1.eth', '1.25')
|
->assertJsonPath('data.addresses.1.eth', '1.25')
|
||||||
->assertJsonCount(2, 'data.addresses');
|
->assertJsonCount(2, 'data.addresses');
|
||||||
|
$this->assertStringNotContainsString(
|
||||||
|
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
|
||||||
|
$wallets->getContent()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
@@ -113,10 +117,13 @@ class MnemonicWalletsTest extends TestCase
|
|||||||
->getJson(route('admin.mnemonics.data'))
|
->getJson(route('admin.mnemonics.data'))
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertJsonPath('data.0.id', $mnemonic->id)
|
->assertJsonPath('data.0.id', $mnemonic->id)
|
||||||
->assertJsonPath('data.0.mnemonic', '已保存(12词)')
|
->assertJsonPath('data.0.mnemonic', 'abandon *** about')
|
||||||
->assertJsonPath('data.0.wallets_url', route('admin.mnemonics.wallets', $mnemonic))
|
->assertJsonPath('data.0.wallets_url', route('admin.mnemonics.wallets', $mnemonic))
|
||||||
->assertJsonPath('data.0.refresh_url', route('admin.mnemonics.wallets.refresh', $mnemonic));
|
->assertJsonPath('data.0.refresh_url', route('admin.mnemonics.wallets.refresh', $mnemonic));
|
||||||
$this->assertStringNotContainsString('abandon', $list->getContent());
|
$this->assertStringNotContainsString(
|
||||||
|
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
|
||||||
|
$list->getContent()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
|
|||||||
Reference in New Issue
Block a user