Skip to content

Commit 877ba6e

Browse files
authored
Merge pull request #22 from hippo-protocol/feature/ibc-asset
feat: add metadata for usdt,usdc
2 parents ef28718 + 4a36c75 commit 877ba6e

File tree

4 files changed

+60
-16
lines changed

4 files changed

+60
-16
lines changed

lib/components/TxDialog/index.vue

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,46 @@ const advance = ref(false);
100100
const sending = ref(false);
101101
const balance = ref([] as Coin[]);
102102
const metadatas = ref({} as Record<string, CoinMetadata>);
103+
const ibcMetadatas = ref({
104+
'ibc/6C9D4572489D0C80E14D39C8D0075CE0BBB0779FD582374448E96DB293325643': {
105+
base: 'ibc/6C9D4572489D0C80E14D39C8D0075CE0BBB0779FD582374448E96DB293325643',
106+
name: 'Tether USD',
107+
description: 'Tether USD',
108+
display: 'usdt',
109+
symbol: 'USDT',
110+
denom_units: [
111+
{
112+
denom: 'ibc/6C9D4572489D0C80E14D39C8D0075CE0BBB0779FD582374448E96DB293325643',
113+
exponent: 0,
114+
aliases: []
115+
},
116+
{
117+
denom: 'usdt',
118+
exponent: 6,
119+
aliases: []
120+
},
121+
]
122+
},
123+
"ibc/F5FABF52B54E65064B57BF6DBD8E5FAD22CEE9F4B8A57ADBB20CCD0173AA72A4": {
124+
base: 'ibc/F5FABF52B54E65064B57BF6DBD8E5FAD22CEE9F4B8A57ADBB20CCD0173AA72A4',
125+
name: 'USD Coin',
126+
description: 'USD Coin',
127+
display: 'usdc',
128+
symbol: 'USDC',
129+
denom_units: [
130+
{
131+
denom: 'ibc/F5FABF52B54E65064B57BF6DBD8E5FAD22CEE9F4B8A57ADBB20CCD0173AA72A4',
132+
exponent: 0,
133+
aliases: []
134+
},
135+
{
136+
denom: 'usdc',
137+
exponent: 6,
138+
aliases: []
139+
},
140+
]
141+
}
142+
} as Record<string, CoinMetadata>);
103143
const emit = defineEmits(['submited', 'confirmed', 'view']);
104144
105145
// functional variable
@@ -191,11 +231,15 @@ async function initData() {
191231
})
192232
.catch(() => { });
193233
if (coin.denom.startsWith('ibc/')) {
194-
getIBCDenomMetadata(coin.denom)
195-
.then((meta) => {
196-
if (meta) metadatas.value[coin.denom] = meta;
197-
})
198-
.catch(() => { });
234+
if (ibcMetadatas.value[coin.denom]) {
235+
metadatas.value[coin.denom] = ibcMetadatas.value[coin.denom];
236+
} else {
237+
getIBCDenomMetadata(coin.denom)
238+
.then((meta) => {
239+
if (meta) metadatas.value[coin.denom] = meta;
240+
})
241+
.catch(() => { });
242+
}
199243
}
200244
});
201245
});

lib/components/TxDialog/messages/Send.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ const amount = ref('');
1717
const recipient = ref('');
1818
const denom = ref('');
1919
const amountDenom = ref('hp')
20-
const convert = new TokenUnitConverter(props.metadata);
2120
2221
const msgs = computed(() => {
22+
const convert = new TokenUnitConverter(props.metadata);
2323
return [
2424
{
2525
typeUrl: '/cosmos.bank.v1beta1.MsgSend',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"@types/bignumber.js": "^5.0.0",
4848
"@types/lodash": "^4.17.19",
4949
"buffer": "^6.0.3",
50-
"chain-registry": "^2.0.13",
50+
"chain-registry": "^2.0.24",
5151
"cosmjs-types": "0.9.0",
5252
"cross-fetch": "^3.1.5",
5353
"daisyui": "^3.1.0",

yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
dependencies:
2727
"@babel/runtime" "^7.19.4"
2828

29-
"@chain-registry/types@^2.0.13":
30-
version "2.0.13"
31-
resolved "https://registry.yarnpkg.com/@chain-registry/types/-/types-2.0.13.tgz#5f1ceb19337aad93186d599e490fa6ec2bb913b5"
32-
integrity sha512-gfx45go8omcFri3s6BavspQyWb9McWW9WYagLobTDMWGB9kksmmIq3OzOzDodAvkf0q97yj3Z822Y8TMlOc6bg==
29+
"@chain-registry/types@^2.0.24":
30+
version "2.0.24"
31+
resolved "https://registry.yarnpkg.com/@chain-registry/types/-/types-2.0.24.tgz#7d8361182a3146b082ac4124d58bafe5632310d1"
32+
integrity sha512-jYvi5cMuvAplQAm2FT8emqF6FZ+mu6nt24oOxijzw2ETNL1YoGOlP+nXD8MikyIgZRroxby81NqqmgauF6WeZg==
3333

3434
"@chainsafe/as-sha256@^0.4.1":
3535
version "0.4.1"
@@ -1662,12 +1662,12 @@ caniuse-lite@^1.0.30001464, caniuse-lite@^1.0.30001489:
16621662
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001492.tgz"
16631663
integrity sha512-2efF8SAZwgAX1FJr87KWhvuJxnGJKOnctQa8xLOskAXNXq8oiuqgl6u1kk3fFpsp3GgvzlRjiK1sl63hNtFADw==
16641664

1665-
chain-registry@^2.0.13:
1666-
version "2.0.13"
1667-
resolved "https://registry.yarnpkg.com/chain-registry/-/chain-registry-2.0.13.tgz#a78344f91fe18a74a459aab224b76ca41a78e2f7"
1668-
integrity sha512-1Ov6PuFdWXAy+epQYQUebMatueO25z+F3K31Rhn95nn/fhl3Xwft37M7f+oqvyNDwT4rsZQw04BJ1raZ06EdKg==
1665+
chain-registry@^2.0.24:
1666+
version "2.0.24"
1667+
resolved "https://registry.yarnpkg.com/chain-registry/-/chain-registry-2.0.24.tgz#2ce2da075cb14b503b2f133fb730dce58276c17c"
1668+
integrity sha512-VW4sUrEKNoC39tFL/8748ATyvX/dV5qWqQHsx/Fh3UMk5hR5qzSBk67qw1VJqcAv/tbdoaELJKa6xZm7W73LhA==
16691669
dependencies:
1670-
"@chain-registry/types" "^2.0.13"
1670+
"@chain-registry/types" "^2.0.24"
16711671

16721672
chalk@^2.4.1:
16731673
version "2.4.2"

0 commit comments

Comments
 (0)