Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: optimize eth example #243

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/example/components/chains/ethereum/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,12 @@ export default function Example() {
/>
<ApiPayload
title="wallet_watchAsset"
description="添加 Token"
description="添加资产 Token、NFT(EIP 747)"
presupposeParams={params.watchAsset}
onExecute={async (request) => {
const res = await provider?.request({
'method': 'wallet_watchAsset',
'params': [JSON.parse(request)],
'params': JSON.parse(request),
});
return JSON.stringify(res);
}}
Expand Down
71 changes: 55 additions & 16 deletions packages/example/components/chains/ethereum/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,35 +219,74 @@ export default {
}),
watchAsset: [
{
'id': 'watchAsset erc20',
'name': '添加 ERC20 资产',
'description': '添加 ERC20 资产',
'id': 'watchAsset erc20 foo',
'name': '主网 FOO ERC20',
'description': '测试添加主网 FOO ERC20 资产',
'value': JSON.stringify({
'type': 'ERC20',
type: 'ERC20',
options: {
address: '0xa9b4d559a98ff47c83b74522b7986146538cd4df',
symbol: 'FOO',
decimals: 18,
image: 'https://foo.io/token-image.svg',
},
}),
},
{
'id': 'watchAsset ERC721 Lido',
'name': '主网 Lido ERC721',
'description': '测试主网 Lido: stETH Withdrawal NFT ERC721 资产',
'value': JSON.stringify({
'type': 'ERC721',
'options': {
'address': '0xb60e8dd61c5d32be8058bb8eb970870f07233155',
'symbol': 'FOO',
'decimals': 18,
'image': 'https://foo.io/token-image.svg',
'address': '0x889edc2edab5f40e902b864ad4d7ade8e412f9b1',
'tokenId': '50632',
},
}),
},
{
'id': 'watchAsset ERC1155 Lido',
'name': '主网 ERC1155',
'description': '测试添加主网 ERC1155 资产',
'value': JSON.stringify({
'type': 'ERC1155',
'options': {
'address': '0xabcdef0123456789abcdef0123456789abcdef01',
'tokenId': '1337',
},
}),
},
{
'id': 'watchAsset erc20 Polygon WETH',
'name': 'Polygon WETH ERC20',
'description': '测试添加 Polygon WETH 资产',
'value': JSON.stringify({
type: 'ERC20',
options: {
address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
symbol: 'WETH',
decimals: 18,
image: 'https://polygonscan.com/token/images/wETH_32.png',
},
}),
},
{
'id': 'watchAsset ERC721',
'name': '添加 ERC721 资产',
'description': '暂时不支持',
'id': 'watchAsset ERC721 Polygon unstoppable',
'name': 'Polygon Unstoppable ERC721',
'description': '测试 Polygon Unstoppable ERC721 资产',
'value': JSON.stringify({
'type': 'ERC721',
'options': {
'address': '0x123456789abcdef0123456789abcdef01234567',
'tokenId': '42',
'address': '0xa9a6a3626993d487d2dbda3173cf58ca1a9d9e9f',
'tokenId':
'17893201811739899534133387548294644234750447072813328765681112569786468116764',
},
}),
},
{
'id': 'watchAsset ERC1155',
'name': '资产 ERC1155 资产',
'description': '暂时不支持',
'id': 'watchAsset ERC1155 Polygon Lido',
'name': 'Polygon ERC1155',
'description': '测试添加 Polygon ERC1155 资产',
'value': JSON.stringify({
'type': 'ERC1155',
'options': {
Expand Down
12 changes: 11 additions & 1 deletion packages/example/components/chains/nostr/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ export default {
},
],
signSchnorr: [
{
id: 'signSchnorr-32HexString',
name: '32 位 Hex String',
value: '2118c65161c7d68b4bdbe1374f658532670057ab1bb0c99937d0ff7cff45cb5e',
},
{
id: 'signSchnorr',
name: 'signSchnorr',
name: 'Hex String',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

建议优化命名以保持一致性

将 "Hex String" 改为 "十六进制字符串" 会更符合中文使用场景,并与其他命名保持一致。

-      name: 'Hex String',
+      name: '十六进制字符串',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name: 'Hex String',
name: '十六进制字符串',

value: '010203',
},
// {
// id: 'signSchnorr-text',
// name: '普通文本',
// value: 'some text here',
// }
Comment on lines +25 to +29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

建议移除已注释的代码

注释掉的代码段应该直接删除,而不是保留在代码中。如果需要保留这些信息,建议记录在文档中。

-    // {
-    //   id: 'signSchnorr-text',
-    //   name: '普通文本',
-    //   value: 'some text here',
-    // }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// {
// id: 'signSchnorr-text',
// name: '普通文本',
// value: 'some text here',
// }

],
nip04encrypt: [
{
Expand Down
Loading