near / near-enhanced-api-server

https://console.pagoda.co/apis?tab=enhancedApi#/
18 stars 6 forks source link

Unable to parse FT metadata for bridged contracts #43

Open telezhnaya opened 2 years ago

telezhnaya commented 2 years ago

We can't parse FT metadata for

0316eb71485b0ab14103307bf65a021042c6d380.factory.bridge.near
035df12e0f3ac6671126525f1015e47d79dfeddf.factory.bridge.near
059a1f1dea1020297588c316ffc30a58a1a0d4a2.factory.bridge.near
06a00715e6f92210af9d7680b584931faf71a833.factory.bridge.near
0d8775f648430679a709e98d2b0cb6250d2887ef.factory.bridge.near
111111111117dc0aa78b770fa6a738034120c302.factory.bridge.near
1117ac6ad6cdf1a3bc543bad3b133724620522d5.factory.bridge.near
1a7e4e63778b4f12a199c062f3efdd288afcbce8.factory.bridge.near
1ab43204a195a0fd37edec621482afd3792ef90b.factory.bridge.near
1f9840a85d5af5bf1d1762f925bdaddc4201f984.factory.bridge.near
2260fac5e5542a773aa44fbcfedf7c193bc2c599.factory.bridge.near
288f5c0fc03d073378d004201129bc145a4a82fc.factory.bridge.near
30d20208d987713f46dfd34ef128bb16c404d10f.factory.bridge.near
39a15a0695c77cbe5fd4f06ab0ccb7bad62f696f.factory.bridge.near
39fc9e94caeacb435842fadedecb783589f50f5f.factory.bridge.near
3ea8ea4237344c9931214796d9417af1a1180770.factory.bridge.near
429881672b9ae42b8eba0e26cd9c73711b891ca5.factory.bridge.near
43dfc4159d86f3a37a5a4b3d4580b888ad7d4ddd.factory.bridge.near
4691937a7508860f876c9c0a2a617e7d9e945d4b.factory.bridge.near
501ace9c35e60f03a2af4d484f49f9b1efde9f40.factory.bridge.near
508df5aa4746be37b5b6a69684dfd8bdc322219d.factory.bridge.near
514910771af9ca656af840dff83e8264ecf986ca.factory.bridge.near
52a047ee205701895ee06a375492490ec9c597ce.factory.bridge.near
6b175474e89094c44da98b954eedeac495271d0f.factory.bridge.near
6b3595068778dd592e39a122f4f5a5cf09c90fe2.factory.bridge.near
7162469321ae5880f077d250b626f3271b21b903.factory.bridge.near
7d1afa7b718fb893db30a3abc0cfc608aacfebb0.factory.bridge.near
7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.factory.bridge.near
853d955acef822db058eb8505911ed77f175b99e.factory.bridge.near
9aeb50f542050172359a0e1a25a9933bc8c01259.factory.bridge.near
a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near
a4cb0dce4849bdcad2d553e9e68644cf40e26cce.factory.bridge.near
a4ef4b0b23c1fc81d3f9ecf93510e64f58a4a016.factory.bridge.near
aaaaaa20d9e0e2461697782ef11675f668207961.factory.bridge.near
c011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f.factory.bridge.near
c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.factory.bridge.near
c944e90c64b2c07662a292be6244bdf05cda44a7.factory.bridge.near
ca0e7269600d353f70b14ad118a49575455c0f2f.factory.bridge.near
cf3c8be2e2c42331da80ef210e9b1b307c03d36a.factory.bridge.near
d9c2d319cd7e6177336b0a9c93c21cb48d84fb54.factory.bridge.near
dac17f958d2ee523a2206206994597c13d831ec7.factory.bridge.near
de30da39c46104798bb5aa3fe8b9e0e1f348163f.factory.bridge.near
dfdb7f72c1f195c5951a234e8db9806eb0635346.factory.bridge.near
e99de844ef3ef72806cf006224ef3b813e82662f.factory.bridge.near
ea7cc765ebc94c4805e3bff28d7e4ae48d06468a.factory.bridge.near
f56b164efd3cfc02ba739b719b6526a6fa1ca32a.factory.bridge.near
f5cfbc74057c610c8ef151a439252680ac68c6dc.factory.bridge.near
ff20817765cb7f73d4bde2e66e067e58d11095c2.factory.bridge.near

They do not follow NEP format https://nomicon.io/Standards/Tokens/FungibleToken/Metadata https://github.com/near/near-enhanced-api-server/blob/main/src/modules/coin/data_provider/metadata.rs#L21

telezhnaya commented 2 years ago

The same implementation works fine with all the other contracts:

1.contract.portalbridge.near
2.contract.portalbridge.near
3.contract.portalbridge.near
4.contract.portalbridge.near
6ebee61d68652fba1212afde0a7b6c8904d43f8b0c4cc337b2ece68b3bdf4a2a
9b204442fe63137a47930b78976c4f1a7c34d555e46fb51f614d0801520cac01
ato.tkn.near
aurora
aurora.tkn.near
avb.tkn.near
baby.tkn.near
beer.tkn.near
bones.tkn.near
boo.tkn.near
cart.tkn.near
cb.tkn.near
cdcode02.near
cdot.tkn.near
cheems.tkn.near
chromeknightsft.near
coin.asac.near
cointiva.tamada.near
confuzed.tkn.near
cont.tkn.near
convtest.near
craftingrusd.near
dacha.tkn.near
damn.tkn.near
dao.tkn.near
dcity.tkn.near
duck.tkn.near
elt.tkn.near
embr.playember_reserve.near
far.tkn.near
finarix.near
firerune.tkn.near
first.tkn.near
fradao.tkn.near
fritz.tkn.near
ft.metafoxonry.near
ft.nekotoken.near
ft.purefi_main.near
ftv2.nekotoken.near
fx.tkn.near
gear.enleap.near
gld.tkn.near
golddigger.tkn.near
gold.tkn.near
groove.tkn.near
gza.tkn.near
hak.tkn.near
haloutc.near
hbsc.tkn.near
hrt.tkn.near
hype.tkn.near
ikenga.tkn.near
illiapolosukhin.tkn.near
infinity.tkn.near
inspira.near
ixtm.near
kkd.tkn.near
kongztoken.near
kotya.tkn.near
kpr.tkn.near
ktch.tkn.near
lgbt.tkn.near
linear-protocol.near
lolcoin.qbit.near
loom.tkn.near
magic.tkn.near
marmaj.tkn.near
mbga.tkn.near
meritocracy.tkn.near
metrop.near
mike.tkn.near
mrktng.tkn.near
mvp.tkn.near
nb.tkn.near
nd.tkn.near
nearbit.tkn.near
neardog.tkn.near
near_flip.near
nearkat.tkn.near
nearnft.tkn.near
nearpunk.tkn.near
near_starter_index_token.near
near_starter_token.near
neir.tkn.near
nexp.near
nftm.tkn.near
nk.tkn.near
nmeme.tkn.near
np.tkn.near
ns.tkn.near
nut.tkn.near
otdai.tkn.near
pa.tkn.near
peter.tkn.near
play.tkn.near
poketa.tkn.near
purrr.tkn.near
pw.tkn.near
rekt.tkn.near
rimjob.tkn.near
rocketbois-reward.near
rocket-staking.near
rustyore.tkn.near
rvndl.tkn.near
ser.tkn.near
shit.tkn.near
skilltoken.allskills.near
snap.tkn.near
socialmeet.tkn.near
soultoken.near
taliban.tkn.near
tao.tkn.near
testing.tkn.near
test.sweat
tia-token.theiadev.near
timur.tkn.near
tkn_artfans.near
toes.tkn.near
token.cryptoblessing.near
token.elcafecartel.near
token.paras.near
token.pembrock.near
token.skyward.near
token.stlb.near
token.sweat
tsoy.tkn.near
ukc.tkn.near
usd.tkn.near
usdt.tether-token.near
usn
utopia.secretskelliessociety.near
vow_token.near
whuffie.tkn.near
wnear-at-120-0.wentokensir.near
wnear-at-150-0.wentokensir.near
wnear-at-40-0.wentokensir.near
wnear-at-80-0.wentokensir.near
wrap.near
xxx.tkn.near
ynp.tkn.near
frol commented 2 years ago

@telezhnaya What is the error you observe when you try parsing the metadata? Their metadata looks fine to me:

$ near-cli-rs contract call-function as-read-only c944e90c64b2c07662a292be6244bdf05cda44a7.factory.bridge.near ft_metadata json-args {} network-config mainnet now
{
  "decimals": 18,
  "icon": null,
  "name": "Graph Token",
  "reference": "",
  "reference_hash": "",
  "spec": "ft-1.0.0",
  "symbol": "GRT"
}
telezhnaya commented 2 years ago

@frol We can't deserialise it with serde

Serialization failure: Error(\"invalid type: string \\\"\\\", expected a sequence\", line: 1, column: 2082)",

I also tried to deserialise it with Borsh, I get

Err(
    Custom {
        kind: InvalidInput,
        error: "Unexpected length of input",
    },
)

That's for 0316eb71485b0ab14103307bf65a021042c6d380.factory.bridge.near, I took the first from the list

telezhnaya commented 2 years ago

They have reference_hash with an empty string inside, that's why we have the issue, we require it to be valid Base64VecU8 I know how to fix that

frol commented 2 years ago

@telezhnaya Your Base64VecU8 type misses proper serialization/deserialization implementation, see #[serde(with = "base64_bytes")] in near-sdk-rs:

https://docs.rs/near-sdk/latest/src/near_sdk/json_types/vector.rs.html#6

These contracts are fine, it is a bug in this project.

telezhnaya commented 2 years ago

I decided just to get rid of Base64VecU8 restriction, it's not even a part of NEP, so empty string is a valid string and all bridged contracts are now parsed successfully It's fixed in a branch, I'll merge it one day

frol commented 2 years ago

@telezhnaya Can you reference the commit here just for future reference?

telezhnaya commented 2 years ago

I'll surely do when I merge it, I'll anyway finalise it in the next 1-2 weeks Now it's here https://github.com/near/near-enhanced-api-server/commit/c9586bac47e42321efc93d52c654003bc680cb97