@subwallet/extension-base 0.8.4-0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (867) hide show
  1. package/background/KoniTypes.d.ts +696 -506
  2. package/background/KoniTypes.js +149 -51
  3. package/background/RequestBytesSign.d.ts +1 -1
  4. package/background/RequestExtrinsicSign.d.ts +1 -1
  5. package/background/errors/BalanceError.d.ts +6 -0
  6. package/background/errors/BalanceError.js +33 -0
  7. package/background/errors/EvmProviderError.d.ts +6 -0
  8. package/background/errors/EvmProviderError.js +45 -0
  9. package/background/errors/ProviderError.d.ts +6 -0
  10. package/background/errors/ProviderError.js +32 -0
  11. package/background/errors/SWError.d.ts +12 -0
  12. package/background/errors/SWError.js +18 -0
  13. package/background/errors/TransactionError.d.ts +6 -0
  14. package/background/errors/TransactionError.js +61 -0
  15. package/background/handlers/Extension.d.ts +3 -1
  16. package/background/handlers/Extension.js +7 -11
  17. package/background/handlers/State.d.ts +5 -1
  18. package/background/handlers/State.js +54 -30
  19. package/background/handlers/Tabs.js +2 -2
  20. package/background/types.d.ts +20 -13
  21. package/background/warnings/SWWarning.d.ts +7 -0
  22. package/{errors/SubWalletProviderError.js → background/warnings/SWWarning.js} +4 -3
  23. package/background/warnings/TransactionWarning.d.ts +6 -0
  24. package/background/warnings/TransactionWarning.js +19 -0
  25. package/cjs/background/KoniTypes.js +151 -58
  26. package/cjs/background/errors/BalanceError.js +39 -0
  27. package/cjs/background/errors/EvmProviderError.js +52 -0
  28. package/cjs/background/errors/EvmRpcError.js +21 -0
  29. package/cjs/background/errors/ProviderError.js +39 -0
  30. package/cjs/background/errors/SWError.js +25 -0
  31. package/cjs/background/errors/SubWalletProviderError.js +17 -0
  32. package/cjs/background/errors/TransactionError.js +67 -0
  33. package/cjs/background/handlers/Extension.js +7 -10
  34. package/cjs/background/handlers/State.js +57 -32
  35. package/cjs/background/handlers/Tabs.js +2 -2
  36. package/cjs/background/warnings/SWWarning.js +18 -0
  37. package/cjs/background/warnings/TransactionWarning.js +26 -0
  38. package/cjs/constants/ethereum.js +19 -0
  39. package/cjs/constants/i18n.js +32 -0
  40. package/cjs/constants/index.js +95 -0
  41. package/cjs/constants/staking.js +14 -0
  42. package/cjs/defaults.js +4 -2
  43. package/cjs/koni/api/coingecko.js +46 -0
  44. package/cjs/koni/api/donate.js +20 -0
  45. package/cjs/koni/api/dotsama/balance.js +568 -0
  46. package/cjs/koni/api/dotsama/crowdloan.js +145 -0
  47. package/cjs/koni/api/dotsama/parseTransaction.js +100 -0
  48. package/cjs/koni/api/dotsama/transfer.js +164 -0
  49. package/cjs/koni/api/dotsama/typeRegistry.js +13 -0
  50. package/cjs/koni/api/nft/acala_nft/index.js +153 -0
  51. package/cjs/koni/api/nft/bit.country/index.js +127 -0
  52. package/cjs/koni/api/nft/config.js +144 -0
  53. package/cjs/koni/api/nft/evm_nft/index.js +169 -0
  54. package/cjs/koni/api/nft/index.js +150 -0
  55. package/cjs/koni/api/nft/karura_nft/index.js +157 -0
  56. package/cjs/koni/api/nft/nft.js +96 -0
  57. package/cjs/koni/api/nft/quartz_nft/index.js +207 -0
  58. package/cjs/koni/api/nft/quartz_nft/protobuf.js +85 -0
  59. package/cjs/koni/api/nft/rmrk_nft/index.js +260 -0
  60. package/cjs/koni/api/nft/statemine_nft/index.js +144 -0
  61. package/cjs/koni/api/nft/transfer.js +102 -0
  62. package/cjs/koni/api/nft/unique_nft/index.js +198 -0
  63. package/cjs/koni/api/nft/unique_nft/protobuf.js +93 -0
  64. package/cjs/koni/api/nft/unique_nft/runtime_types.js +122 -0
  65. package/cjs/koni/api/nft/unique_nft/uniqueNftV2.js +70 -0
  66. package/cjs/koni/api/nft/wasm_nft/index.js +295 -0
  67. package/cjs/koni/api/nft/wasm_nft/utils.js +19 -0
  68. package/cjs/koni/api/staking/bonding/amplitude.js +183 -0
  69. package/cjs/koni/api/staking/bonding/astar.js +458 -0
  70. package/cjs/koni/api/staking/bonding/index.js +108 -0
  71. package/cjs/koni/api/staking/bonding/paraChain.js +254 -0
  72. package/cjs/koni/api/staking/bonding/relayChain.js +350 -0
  73. package/cjs/koni/api/staking/bonding/utils.js +222 -0
  74. package/cjs/koni/api/staking/config.js +47 -0
  75. package/cjs/koni/api/staking/index.js +77 -0
  76. package/cjs/koni/api/staking/paraChain.js +226 -0
  77. package/cjs/koni/api/staking/relayChain.js +171 -0
  78. package/cjs/koni/api/staking/subsquidStaking.js +109 -0
  79. package/cjs/koni/api/staking/utils.js +17 -0
  80. package/cjs/koni/api/subquery/__generated__/DotSamaHistory.js +1 -0
  81. package/cjs/koni/api/subquery/subquery.js +21 -0
  82. package/cjs/koni/api/tokens/evm/balance.js +15 -0
  83. package/cjs/koni/api/tokens/evm/transfer.js +112 -0
  84. package/cjs/koni/api/tokens/evm/web3.js +17 -0
  85. package/cjs/koni/api/tokens/index.js +17 -0
  86. package/cjs/koni/api/tokens/wasm/index.js +36 -0
  87. package/cjs/koni/api/xcm/astar.js +160 -0
  88. package/cjs/koni/api/xcm/index.js +149 -0
  89. package/cjs/koni/api/xcm/moonbeamXcm.js +80 -0
  90. package/cjs/koni/api/xcm/polkadotXcm.js +58 -0
  91. package/cjs/koni/api/xcm/statemintXcm.js +197 -0
  92. package/cjs/koni/api/xcm/substrateXcm.js +213 -0
  93. package/cjs/koni/api/xcm/utils.js +63 -0
  94. package/cjs/koni/api/xcm/xTokens.js +61 -0
  95. package/cjs/koni/api/xcm/xcmPallet.js +52 -0
  96. package/cjs/koni/background/cron.js +208 -0
  97. package/cjs/koni/background/events.js +14 -0
  98. package/cjs/koni/background/handlers/Extension.js +3092 -0
  99. package/cjs/koni/background/handlers/Mobile.js +138 -0
  100. package/cjs/koni/background/handlers/State.js +1405 -0
  101. package/cjs/koni/background/handlers/Tabs.js +797 -0
  102. package/cjs/koni/background/handlers/index.js +90 -0
  103. package/cjs/koni/background/subscription.js +281 -0
  104. package/cjs/koni/migration/Base.js +20 -0
  105. package/cjs/koni/migration/index.js +45 -0
  106. package/cjs/koni/migration/scripts/ChangeRouteToHome.js +22 -0
  107. package/cjs/koni/migration/scripts/ClearOldStorage.js +24 -0
  108. package/cjs/koni/migration/scripts/RemoveWrongCrowdloan.js +19 -0
  109. package/cjs/koni/migration/scripts/RemoveWrongTransactionHistoriesFromStore.js +36 -0
  110. package/cjs/koni/migration/scripts/ResetTransactionHistoryEventIdx.js +21 -0
  111. package/cjs/koni/migration/scripts/index.js +22 -0
  112. package/cjs/koni/page/SubWalleEvmProvider.js +142 -0
  113. package/cjs/koni/page/index.js +16 -0
  114. package/cjs/packageInfo.js +1 -1
  115. package/cjs/page/index.js +3 -2
  116. package/cjs/services/asset-service/index.js +91 -0
  117. package/cjs/services/balance-service/index.js +108 -0
  118. package/cjs/services/chain-service/constants.js +231 -0
  119. package/cjs/services/chain-service/handler/EvmChainHandler.js +144 -0
  120. package/cjs/services/chain-service/handler/SubstrateChainHandler.js +348 -0
  121. package/cjs/services/chain-service/handler/light-client/index.js +120 -0
  122. package/cjs/services/chain-service/handler/types.js +20 -0
  123. package/cjs/services/chain-service/heath-check/index.js +60 -0
  124. package/cjs/services/chain-service/helper/api-helper/chain/crust-maxwell.js +108 -0
  125. package/cjs/services/chain-service/helper/api-helper/chain/index.js +17 -0
  126. package/cjs/services/chain-service/helper/api-helper/index.js +35 -0
  127. package/cjs/services/chain-service/helper/api-helper/spec/acala.js +11 -0
  128. package/cjs/services/chain-service/helper/api-helper/spec/ajuna.js +22 -0
  129. package/cjs/services/chain-service/helper/api-helper/spec/altair.js +31 -0
  130. package/cjs/services/chain-service/helper/api-helper/spec/apron.js +24 -0
  131. package/cjs/services/chain-service/helper/api-helper/spec/ares-gladios.js +191 -0
  132. package/cjs/services/chain-service/helper/api-helper/spec/ares-parachain.js +192 -0
  133. package/cjs/services/chain-service/helper/api-helper/spec/astar.js +44 -0
  134. package/cjs/services/chain-service/helper/api-helper/spec/automata.js +43 -0
  135. package/cjs/services/chain-service/helper/api-helper/spec/basilisk.js +139 -0
  136. package/cjs/services/chain-service/helper/api-helper/spec/beresheet.js +12 -0
  137. package/cjs/services/chain-service/helper/api-helper/spec/bifrost-asgard.js +11 -0
  138. package/cjs/services/chain-service/helper/api-helper/spec/bifrost-parachain.js +11 -0
  139. package/cjs/services/chain-service/helper/api-helper/spec/bifrost.js +11 -0
  140. package/cjs/services/chain-service/helper/api-helper/spec/bitcountry-pioneer.js +11 -0
  141. package/cjs/services/chain-service/helper/api-helper/spec/bitcountry-rococo.js +122 -0
  142. package/cjs/services/chain-service/helper/api-helper/spec/bitcountry.js +84 -0
  143. package/cjs/services/chain-service/helper/api-helper/spec/canvas.js +31 -0
  144. package/cjs/services/chain-service/helper/api-helper/spec/centrifuge-chain.js +77 -0
  145. package/cjs/services/chain-service/helper/api-helper/spec/centrifuge.js +31 -0
  146. package/cjs/services/chain-service/helper/api-helper/spec/chainx.js +403 -0
  147. package/cjs/services/chain-service/helper/api-helper/spec/clover-rococo.js +68 -0
  148. package/cjs/services/chain-service/helper/api-helper/spec/clover.js +34 -0
  149. package/cjs/services/chain-service/helper/api-helper/spec/coinversation.js +24 -0
  150. package/cjs/services/chain-service/helper/api-helper/spec/competitors-club.js +84 -0
  151. package/cjs/services/chain-service/helper/api-helper/spec/crab.js +11 -0
  152. package/cjs/services/chain-service/helper/api-helper/spec/crown-sterling.js +55 -0
  153. package/cjs/services/chain-service/helper/api-helper/spec/crust.js +11 -0
  154. package/cjs/services/chain-service/helper/api-helper/spec/cumulus-test-parachain.js +24 -0
  155. package/cjs/services/chain-service/helper/api-helper/spec/darwinia.js +11 -0
  156. package/cjs/services/chain-service/helper/api-helper/spec/datahighway.js +240 -0
  157. package/cjs/services/chain-service/helper/api-helper/spec/dock-mainnet.js +16 -0
  158. package/cjs/services/chain-service/helper/api-helper/spec/dock-testnet.js +16 -0
  159. package/cjs/services/chain-service/helper/api-helper/spec/dolphin.js +29 -0
  160. package/cjs/services/chain-service/helper/api-helper/spec/dotmog.js +65 -0
  161. package/cjs/services/chain-service/helper/api-helper/spec/eave.js +416 -0
  162. package/cjs/services/chain-service/helper/api-helper/spec/edgeware.js +11 -0
  163. package/cjs/services/chain-service/helper/api-helper/spec/encointer-node-notee.js +75 -0
  164. package/cjs/services/chain-service/helper/api-helper/spec/encointer-node-teeproxy.js +52 -0
  165. package/cjs/services/chain-service/helper/api-helper/spec/encointer-para.js +79 -0
  166. package/cjs/services/chain-service/helper/api-helper/spec/equilibrium.js +109 -0
  167. package/cjs/services/chain-service/helper/api-helper/spec/fantour.js +70 -0
  168. package/cjs/services/chain-service/helper/api-helper/spec/galital-parachain.js +65 -0
  169. package/cjs/services/chain-service/helper/api-helper/spec/galital.js +70 -0
  170. package/cjs/services/chain-service/helper/api-helper/spec/galois.js +54 -0
  171. package/cjs/services/chain-service/helper/api-helper/spec/gamepower.js +71 -0
  172. package/cjs/services/chain-service/helper/api-helper/spec/genshiro.js +31 -0
  173. package/cjs/services/chain-service/helper/api-helper/spec/hanonycash.js +33 -0
  174. package/cjs/services/chain-service/helper/api-helper/spec/hydrate.js +59 -0
  175. package/cjs/services/chain-service/helper/api-helper/spec/idavoll.js +24 -0
  176. package/cjs/services/chain-service/helper/api-helper/spec/index.js +272 -0
  177. package/cjs/services/chain-service/helper/api-helper/spec/integritee.js +35 -0
  178. package/cjs/services/chain-service/helper/api-helper/spec/interbtc.js +60 -0
  179. package/cjs/services/chain-service/helper/api-helper/spec/ipse.js +113 -0
  180. package/cjs/services/chain-service/helper/api-helper/spec/jupiter-rococo.js +24 -0
  181. package/cjs/services/chain-service/helper/api-helper/spec/jupiter.js +70 -0
  182. package/cjs/services/chain-service/helper/api-helper/spec/khala.js +11 -0
  183. package/cjs/services/chain-service/helper/api-helper/spec/kilt.js +11 -0
  184. package/cjs/services/chain-service/helper/api-helper/spec/konomi.js +24 -0
  185. package/cjs/services/chain-service/helper/api-helper/spec/kpron.js +24 -0
  186. package/cjs/services/chain-service/helper/api-helper/spec/kulupu.js +64 -0
  187. package/cjs/services/chain-service/helper/api-helper/spec/kusari.js +45 -0
  188. package/cjs/services/chain-service/helper/api-helper/spec/kylin.js +36 -0
  189. package/cjs/services/chain-service/helper/api-helper/spec/laminar.js +11 -0
  190. package/cjs/services/chain-service/helper/api-helper/spec/litentry.js +24 -0
  191. package/cjs/services/chain-service/helper/api-helper/spec/mangata.js +20 -0
  192. package/cjs/services/chain-service/helper/api-helper/spec/manta.js +29 -0
  193. package/cjs/services/chain-service/helper/api-helper/spec/mathchain.js +54 -0
  194. package/cjs/services/chain-service/helper/api-helper/spec/moonbeam.js +11 -0
  195. package/cjs/services/chain-service/helper/api-helper/spec/moonsama-development.js +24 -0
  196. package/cjs/services/chain-service/helper/api-helper/spec/mybank.js +87 -0
  197. package/cjs/services/chain-service/helper/api-helper/spec/neatcoin.js +32 -0
  198. package/cjs/services/chain-service/helper/api-helper/spec/neumann.js +55 -0
  199. package/cjs/services/chain-service/helper/api-helper/spec/nftmart.js +134 -0
  200. package/cjs/services/chain-service/helper/api-helper/spec/nodle.js +53 -0
  201. package/cjs/services/chain-service/helper/api-helper/spec/opal.js +15 -0
  202. package/cjs/services/chain-service/helper/api-helper/spec/opportunity.js +12 -0
  203. package/cjs/services/chain-service/helper/api-helper/spec/origintrail.js +206 -0
  204. package/cjs/services/chain-service/helper/api-helper/spec/pangolin.js +11 -0
  205. package/cjs/services/chain-service/helper/api-helper/spec/pangoro.js +12 -0
  206. package/cjs/services/chain-service/helper/api-helper/spec/parallel.js +11 -0
  207. package/cjs/services/chain-service/helper/api-helper/spec/parami.js +21 -0
  208. package/cjs/services/chain-service/helper/api-helper/spec/phoenix.js +52 -0
  209. package/cjs/services/chain-service/helper/api-helper/spec/pichiu.js +36 -0
  210. package/cjs/services/chain-service/helper/api-helper/spec/plasm.js +54 -0
  211. package/cjs/services/chain-service/helper/api-helper/spec/polkadex.js +32 -0
  212. package/cjs/services/chain-service/helper/api-helper/spec/polkafoundry.js +43 -0
  213. package/cjs/services/chain-service/helper/api-helper/spec/polymesh.js +21 -0
  214. package/cjs/services/chain-service/helper/api-helper/spec/pontem.js +11 -0
  215. package/cjs/services/chain-service/helper/api-helper/spec/prism.js +24 -0
  216. package/cjs/services/chain-service/helper/api-helper/spec/quartz.js +15 -0
  217. package/cjs/services/chain-service/helper/api-helper/spec/realis.js +42 -0
  218. package/cjs/services/chain-service/helper/api-helper/spec/riochain.js +104 -0
  219. package/cjs/services/chain-service/helper/api-helper/spec/robonomics.js +41 -0
  220. package/cjs/services/chain-service/helper/api-helper/spec/shibuya.js +54 -0
  221. package/cjs/services/chain-service/helper/api-helper/spec/shiden.js +54 -0
  222. package/cjs/services/chain-service/helper/api-helper/spec/snowbridge.js +11 -0
  223. package/cjs/services/chain-service/helper/api-helper/spec/soraSubstrate.js +11 -0
  224. package/cjs/services/chain-service/helper/api-helper/spec/spanner.js +501 -0
  225. package/cjs/services/chain-service/helper/api-helper/spec/stafi.js +25 -0
  226. package/cjs/services/chain-service/helper/api-helper/spec/standard.js +12 -0
  227. package/cjs/services/chain-service/helper/api-helper/spec/subdao.js +21 -0
  228. package/cjs/services/chain-service/helper/api-helper/spec/subgame.js +185 -0
  229. package/cjs/services/chain-service/helper/api-helper/spec/subsocial.js +15 -0
  230. package/cjs/services/chain-service/helper/api-helper/spec/subspace.js +127 -0
  231. package/cjs/services/chain-service/helper/api-helper/spec/substrateContractsNode.js +23 -0
  232. package/cjs/services/chain-service/helper/api-helper/spec/swapdex.js +45 -0
  233. package/cjs/services/chain-service/helper/api-helper/spec/ternoa.js +95 -0
  234. package/cjs/services/chain-service/helper/api-helper/spec/trustbase.js +24 -0
  235. package/cjs/services/chain-service/helper/api-helper/spec/uart.js +289 -0
  236. package/cjs/services/chain-service/helper/api-helper/spec/unique.js +124 -0
  237. package/cjs/services/chain-service/helper/api-helper/spec/unitv.js +25 -0
  238. package/cjs/services/chain-service/helper/api-helper/spec/vln-rococo.js +109 -0
  239. package/cjs/services/chain-service/helper/api-helper/spec/vln.js +45 -0
  240. package/cjs/services/chain-service/helper/api-helper/spec/vodka.js +22 -0
  241. package/cjs/services/chain-service/helper/api-helper/spec/web3games.js +43 -0
  242. package/cjs/services/chain-service/helper/api-helper/spec/westlake.js +305 -0
  243. package/cjs/services/chain-service/helper/api-helper/spec/zCloak.js +46 -0
  244. package/cjs/services/chain-service/helper/api-helper/spec/zeitgeist.js +33 -0
  245. package/cjs/services/chain-service/helper/api-helper/spec/zenlink.js +57 -0
  246. package/cjs/services/chain-service/helper/api-helper/spec/zero.js +11 -0
  247. package/cjs/services/chain-service/helper/api-helper/util.js +25 -0
  248. package/cjs/services/chain-service/helper/index.js +24 -0
  249. package/cjs/services/chain-service/index.js +1154 -0
  250. package/cjs/services/chain-service/types.js +26 -0
  251. package/cjs/services/chain-service/utils.js +387 -0
  252. package/cjs/services/history-service/index.js +110 -0
  253. package/cjs/services/history-service/subsquid-multi-chain-history.js +263 -0
  254. package/cjs/services/migration-service/Base.js +20 -0
  255. package/cjs/services/migration-service/index.js +45 -0
  256. package/cjs/services/migration-service/scripts/ClearOldStorage.js +19 -0
  257. package/cjs/services/migration-service/scripts/MigrateImportedToken.js +49 -0
  258. package/cjs/services/migration-service/scripts/MigrateNetworkSettings.js +39 -0
  259. package/cjs/services/migration-service/scripts/index.js +17 -0
  260. package/cjs/services/notification-service/NotificationService.js +53 -0
  261. package/cjs/services/price-service/coingecko.js +40 -0
  262. package/cjs/services/price-service/index.js +78 -0
  263. package/cjs/services/request-service/constants.js +11 -0
  264. package/cjs/services/request-service/handler/AuthRequestHandler.js +269 -0
  265. package/cjs/services/request-service/handler/EvmRequestHandler.js +217 -0
  266. package/cjs/services/request-service/handler/MetadataRequestHandler.js +85 -0
  267. package/cjs/services/request-service/handler/PopupHandler.js +86 -0
  268. package/cjs/services/request-service/handler/SubstrateRequestHandler.js +105 -0
  269. package/cjs/services/request-service/helper/index.js +82 -0
  270. package/cjs/services/request-service/index.js +158 -0
  271. package/cjs/services/request-service/types.js +1 -0
  272. package/cjs/services/setting-service/SettingService.js +39 -0
  273. package/cjs/services/setting-service/constants.js +14 -0
  274. package/cjs/services/storage-service/DatabaseService.js +228 -0
  275. package/cjs/services/storage-service/databases/index.js +47 -0
  276. package/cjs/services/storage-service/db-stores/Asset.js +20 -0
  277. package/cjs/services/storage-service/db-stores/Balance.js +32 -0
  278. package/cjs/services/storage-service/db-stores/BaseStore.js +29 -0
  279. package/cjs/services/storage-service/db-stores/BaseStoreWithAddress.js +28 -0
  280. package/cjs/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +33 -0
  281. package/cjs/services/storage-service/db-stores/BaseStoreWithChain.js +20 -0
  282. package/cjs/services/storage-service/db-stores/Chain.js +20 -0
  283. package/cjs/services/storage-service/db-stores/ChainStakingMetadata.js +38 -0
  284. package/cjs/services/storage-service/db-stores/Crowdloan.js +23 -0
  285. package/cjs/services/storage-service/db-stores/ExtraDelegationInfo.js +17 -0
  286. package/cjs/services/storage-service/db-stores/Migration.js +13 -0
  287. package/cjs/services/storage-service/db-stores/Nft.js +72 -0
  288. package/cjs/services/storage-service/db-stores/NftCollection.js +30 -0
  289. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +30 -0
  290. package/cjs/services/storage-service/db-stores/Price.js +13 -0
  291. package/cjs/services/storage-service/db-stores/Staking.js +40 -0
  292. package/cjs/services/storage-service/db-stores/Transaction.js +49 -0
  293. package/cjs/services/storage-service/db-stores/index.js +76 -0
  294. package/cjs/services/transaction-service/event-parser/index.js +103 -0
  295. package/cjs/services/transaction-service/helpers/index.js +23 -0
  296. package/cjs/services/transaction-service/index.js +711 -0
  297. package/cjs/services/transaction-service/types.js +1 -0
  298. package/cjs/services/transaction-service/utils.js +32 -0
  299. package/cjs/stores/AccountRef.js +18 -0
  300. package/cjs/stores/Application.js +28 -0
  301. package/cjs/stores/AssetSetting.js +19 -0
  302. package/cjs/stores/Authorize.js +18 -0
  303. package/cjs/stores/Balance.js +18 -0
  304. package/cjs/stores/Crowdloan.js +18 -0
  305. package/cjs/stores/CurrentAccountStore.js +18 -0
  306. package/cjs/stores/CustomEvmToken.js +18 -0
  307. package/cjs/stores/Keyring.js +39 -0
  308. package/cjs/stores/NetworkMap.js +18 -0
  309. package/cjs/stores/Nft.js +18 -0
  310. package/cjs/stores/NftCollection.js +18 -0
  311. package/cjs/stores/Price.js +18 -0
  312. package/cjs/stores/Settings.js +18 -0
  313. package/cjs/stores/Staking.js +18 -0
  314. package/cjs/stores/StakingReward.js +18 -0
  315. package/cjs/stores/SubscribableStore.js +33 -0
  316. package/cjs/stores/TransactionHistory.js +37 -0
  317. package/cjs/stores/TransactionHistoryV2.js +18 -0
  318. package/cjs/stores/TransactionHistoryV3.js +18 -0
  319. package/cjs/stores/index.js +8 -1
  320. package/cjs/utils/address.js +17 -0
  321. package/cjs/utils/eth/mergeTransactionAndSignature.js +22 -0
  322. package/cjs/utils/eth/parseTransaction/base.js +282 -0
  323. package/cjs/utils/eth/parseTransaction/index.js +229 -0
  324. package/cjs/utils/eth/parseTransactionData.js +284 -0
  325. package/cjs/utils/eth.js +76 -0
  326. package/cjs/utils/index.js +313 -1
  327. package/cjs/utils/keyring.js +57 -0
  328. package/cjs/utils/request.js +13 -0
  329. package/constants/i18n.d.ts +2 -0
  330. package/constants/i18n.js +25 -0
  331. package/constants/index.d.ts +25 -0
  332. package/constants/index.js +28 -0
  333. package/constants/staking.d.ts +1 -0
  334. package/constants/staking.js +7 -0
  335. package/defaults.d.ts +3 -2
  336. package/defaults.js +3 -2
  337. package/koni/api/coingecko.d.ts +2 -0
  338. package/koni/api/coingecko.js +37 -0
  339. package/koni/api/donate.d.ts +3 -0
  340. package/koni/api/donate.js +13 -0
  341. package/koni/api/dotsama/balance.d.ts +7 -0
  342. package/koni/api/dotsama/balance.js +556 -0
  343. package/koni/api/dotsama/crowdloan.d.ts +7 -0
  344. package/koni/api/dotsama/crowdloan.js +130 -0
  345. package/koni/api/dotsama/parseTransaction.d.ts +3 -0
  346. package/koni/api/dotsama/parseTransaction.js +93 -0
  347. package/koni/api/dotsama/transfer.d.ts +17 -0
  348. package/koni/api/dotsama/transfer.js +154 -0
  349. package/koni/api/dotsama/typeRegistry.d.ts +3 -0
  350. package/koni/api/dotsama/typeRegistry.js +6 -0
  351. package/koni/api/nft/acala_nft/index.d.ts +18 -0
  352. package/koni/api/nft/acala_nft/index.js +145 -0
  353. package/koni/api/nft/bit.country/index.d.ts +12 -0
  354. package/koni/api/nft/bit.country/index.js +119 -0
  355. package/koni/api/nft/config.d.ts +57 -0
  356. package/koni/api/nft/config.js +110 -0
  357. package/koni/api/nft/evm_nft/index.d.ts +13 -0
  358. package/koni/api/nft/evm_nft/index.js +161 -0
  359. package/koni/api/nft/index.d.ts +22 -0
  360. package/koni/api/nft/index.js +141 -0
  361. package/koni/api/nft/karura_nft/index.d.ts +18 -0
  362. package/koni/api/nft/karura_nft/index.js +148 -0
  363. package/koni/api/nft/nft.d.ts +29 -0
  364. package/koni/api/nft/nft.js +89 -0
  365. package/koni/api/nft/quartz_nft/index.d.ts +62 -0
  366. package/koni/api/nft/quartz_nft/index.js +199 -0
  367. package/koni/api/nft/quartz_nft/protobuf.d.ts +3 -0
  368. package/koni/api/nft/quartz_nft/protobuf.js +78 -0
  369. package/koni/api/nft/rmrk_nft/index.d.ts +10 -0
  370. package/koni/api/nft/rmrk_nft/index.js +252 -0
  371. package/koni/api/nft/statemine_nft/index.d.ts +18 -0
  372. package/koni/api/nft/statemine_nft/index.js +136 -0
  373. package/koni/api/nft/transfer.d.ts +8 -0
  374. package/koni/api/nft/transfer.js +90 -0
  375. package/koni/api/nft/unique_nft/index.d.ts +54 -0
  376. package/koni/api/nft/unique_nft/index.js +189 -0
  377. package/koni/api/nft/unique_nft/protobuf.d.ts +3 -0
  378. package/koni/api/nft/unique_nft/protobuf.js +86 -0
  379. package/koni/api/nft/unique_nft/runtime_types.d.ts +3 -0
  380. package/koni/api/nft/unique_nft/runtime_types.js +115 -0
  381. package/koni/api/nft/unique_nft/uniqueNftV2.d.ts +9 -0
  382. package/koni/api/nft/unique_nft/uniqueNftV2.js +62 -0
  383. package/koni/api/nft/wasm_nft/index.d.ts +17 -0
  384. package/koni/api/nft/wasm_nft/index.js +287 -0
  385. package/koni/api/nft/wasm_nft/utils.d.ts +5 -0
  386. package/koni/api/nft/wasm_nft/utils.js +8 -0
  387. package/koni/api/staking/bonding/amplitude.d.ts +11 -0
  388. package/koni/api/staking/bonding/amplitude.js +170 -0
  389. package/koni/api/staking/bonding/astar.d.ts +19 -0
  390. package/koni/api/staking/bonding/astar.js +436 -0
  391. package/koni/api/staking/bonding/index.d.ts +12 -0
  392. package/koni/api/staking/bonding/index.js +93 -0
  393. package/koni/api/staking/bonding/paraChain.d.ts +12 -0
  394. package/koni/api/staking/bonding/paraChain.js +240 -0
  395. package/koni/api/staking/bonding/relayChain.d.ts +32 -0
  396. package/koni/api/staking/bonding/relayChain.js +329 -0
  397. package/koni/api/staking/bonding/utils.d.ts +142 -0
  398. package/koni/api/staking/bonding/utils.js +198 -0
  399. package/koni/api/staking/config.d.ts +3 -0
  400. package/koni/api/staking/config.js +38 -0
  401. package/koni/api/staking/index.d.ts +6 -0
  402. package/koni/api/staking/index.js +67 -0
  403. package/koni/api/staking/paraChain.d.ts +7 -0
  404. package/koni/api/staking/paraChain.js +216 -0
  405. package/koni/api/staking/relayChain.d.ts +6 -0
  406. package/koni/api/staking/relayChain.js +161 -0
  407. package/koni/api/staking/subsquidStaking.d.ts +3 -0
  408. package/koni/api/staking/subsquidStaking.js +101 -0
  409. package/koni/api/staking/utils.d.ts +2 -0
  410. package/koni/api/staking/utils.js +11 -0
  411. package/koni/api/subquery/__generated__/DotSamaHistory.d.ts +58 -0
  412. package/koni/api/subquery/__generated__/DotSamaHistory.js +1 -0
  413. package/koni/api/subquery/subquery.d.ts +2 -0
  414. package/koni/api/subquery/subquery.js +14 -0
  415. package/koni/api/tokens/evm/balance.d.ts +2 -0
  416. package/koni/api/tokens/evm/balance.js +9 -0
  417. package/koni/api/tokens/evm/transfer.d.ts +17 -0
  418. package/koni/api/tokens/evm/transfer.js +101 -0
  419. package/koni/api/tokens/evm/web3.d.ts +3 -0
  420. package/koni/api/tokens/evm/web3.js +9 -0
  421. package/koni/api/tokens/index.d.ts +1 -0
  422. package/koni/api/tokens/index.js +11 -0
  423. package/koni/api/tokens/wasm/index.d.ts +6 -0
  424. package/koni/api/tokens/wasm/index.js +28 -0
  425. package/koni/api/xcm/index.d.ts +13 -0
  426. package/koni/api/xcm/index.js +141 -0
  427. package/koni/api/xcm/polkadotXcm.d.ts +3 -0
  428. package/koni/api/xcm/polkadotXcm.js +52 -0
  429. package/koni/api/xcm/utils.d.ts +16 -0
  430. package/koni/api/xcm/utils.js +52 -0
  431. package/koni/api/xcm/xTokens.d.ts +3 -0
  432. package/koni/api/xcm/xTokens.js +55 -0
  433. package/koni/api/xcm/xcmPallet.d.ts +3 -0
  434. package/koni/api/xcm/xcmPallet.js +46 -0
  435. package/koni/background/cron.d.ts +37 -0
  436. package/koni/background/cron.js +195 -0
  437. package/koni/background/events.d.ts +1 -0
  438. package/koni/background/events.js +7 -0
  439. package/koni/background/handlers/Extension.d.ts +183 -0
  440. package/koni/background/handlers/Extension.js +3016 -0
  441. package/koni/background/handlers/Mobile.d.ts +21 -0
  442. package/koni/background/handlers/Mobile.js +127 -0
  443. package/koni/background/handlers/State.d.ts +224 -0
  444. package/koni/background/handlers/State.js +1377 -0
  445. package/koni/background/handlers/Tabs.d.ts +47 -0
  446. package/koni/background/handlers/Tabs.js +746 -0
  447. package/koni/background/handlers/index.d.ts +13 -0
  448. package/koni/background/handlers/index.js +76 -0
  449. package/koni/background/subscription.d.ts +32 -0
  450. package/koni/background/subscription.js +267 -0
  451. package/koni/page/SubWalleEvmProvider.d.ts +27 -0
  452. package/koni/page/SubWalleEvmProvider.js +132 -0
  453. package/koni/page/index.d.ts +2 -0
  454. package/koni/page/index.js +9 -0
  455. package/package.json +1423 -10
  456. package/packageInfo.js +1 -1
  457. package/page/index.js +3 -2
  458. package/services/balance-service/index.d.ts +9 -0
  459. package/services/balance-service/index.js +101 -0
  460. package/services/chain-service/constants.d.ts +78 -0
  461. package/services/chain-service/constants.js +213 -0
  462. package/services/chain-service/handler/EvmChainHandler.d.ts +16 -0
  463. package/services/chain-service/handler/EvmChainHandler.js +136 -0
  464. package/services/chain-service/handler/SubstrateChainHandler.d.ts +21 -0
  465. package/services/chain-service/handler/SubstrateChainHandler.js +340 -0
  466. package/services/chain-service/handler/light-client/index.d.ts +4 -0
  467. package/services/chain-service/handler/light-client/index.js +111 -0
  468. package/services/chain-service/handler/types.d.ts +26 -0
  469. package/services/chain-service/handler/types.js +14 -0
  470. package/services/chain-service/heath-check/index.d.ts +3 -0
  471. package/services/chain-service/heath-check/index.js +50 -0
  472. package/services/chain-service/helper/api-helper/chain/crust-maxwell.d.ts +98 -0
  473. package/services/chain-service/helper/api-helper/chain/crust-maxwell.js +103 -0
  474. package/services/chain-service/helper/api-helper/chain/index.d.ts +1943 -0
  475. package/services/chain-service/helper/api-helper/chain/index.js +11 -0
  476. package/services/chain-service/helper/api-helper/index.d.ts +7 -0
  477. package/services/chain-service/helper/api-helper/index.js +18 -0
  478. package/services/chain-service/helper/api-helper/spec/acala.d.ts +42 -0
  479. package/services/chain-service/helper/api-helper/spec/acala.js +5 -0
  480. package/services/chain-service/helper/api-helper/spec/ajuna.d.ts +3 -0
  481. package/services/chain-service/helper/api-helper/spec/ajuna.js +15 -0
  482. package/services/chain-service/helper/api-helper/spec/altair.d.ts +3 -0
  483. package/services/chain-service/helper/api-helper/spec/altair.js +24 -0
  484. package/services/chain-service/helper/api-helper/spec/apron.d.ts +3 -0
  485. package/services/chain-service/helper/api-helper/spec/apron.js +17 -0
  486. package/services/chain-service/helper/api-helper/spec/ares-gladios.d.ts +3 -0
  487. package/services/chain-service/helper/api-helper/spec/ares-gladios.js +184 -0
  488. package/services/chain-service/helper/api-helper/spec/ares-parachain.d.ts +3 -0
  489. package/services/chain-service/helper/api-helper/spec/ares-parachain.js +185 -0
  490. package/services/chain-service/helper/api-helper/spec/astar.d.ts +3 -0
  491. package/services/chain-service/helper/api-helper/spec/astar.js +37 -0
  492. package/services/chain-service/helper/api-helper/spec/automata.d.ts +3 -0
  493. package/services/chain-service/helper/api-helper/spec/automata.js +36 -0
  494. package/services/chain-service/helper/api-helper/spec/basilisk.d.ts +3 -0
  495. package/services/chain-service/helper/api-helper/spec/basilisk.js +132 -0
  496. package/services/chain-service/helper/api-helper/spec/beresheet.d.ts +3 -0
  497. package/services/chain-service/helper/api-helper/spec/beresheet.js +9 -0
  498. package/services/chain-service/helper/api-helper/spec/bifrost-asgard.d.ts +3 -0
  499. package/services/chain-service/helper/api-helper/spec/bifrost-asgard.js +5 -0
  500. package/services/chain-service/helper/api-helper/spec/bifrost-parachain.d.ts +3 -0
  501. package/services/chain-service/helper/api-helper/spec/bifrost-parachain.js +5 -0
  502. package/services/chain-service/helper/api-helper/spec/bifrost.d.ts +3 -0
  503. package/services/chain-service/helper/api-helper/spec/bifrost.js +5 -0
  504. package/services/chain-service/helper/api-helper/spec/bitcountry-pioneer.d.ts +2 -0
  505. package/services/chain-service/helper/api-helper/spec/bitcountry-pioneer.js +5 -0
  506. package/services/chain-service/helper/api-helper/spec/bitcountry-rococo.d.ts +3 -0
  507. package/services/chain-service/helper/api-helper/spec/bitcountry-rococo.js +115 -0
  508. package/services/chain-service/helper/api-helper/spec/bitcountry.d.ts +3 -0
  509. package/services/chain-service/helper/api-helper/spec/bitcountry.js +77 -0
  510. package/services/chain-service/helper/api-helper/spec/canvas.d.ts +3 -0
  511. package/services/chain-service/helper/api-helper/spec/canvas.js +24 -0
  512. package/services/chain-service/helper/api-helper/spec/centrifuge-chain.d.ts +3 -0
  513. package/services/chain-service/helper/api-helper/spec/centrifuge-chain.js +70 -0
  514. package/services/chain-service/helper/api-helper/spec/centrifuge.d.ts +3 -0
  515. package/services/chain-service/helper/api-helper/spec/centrifuge.js +24 -0
  516. package/services/chain-service/helper/api-helper/spec/chainx.d.ts +3 -0
  517. package/services/chain-service/helper/api-helper/spec/chainx.js +396 -0
  518. package/services/chain-service/helper/api-helper/spec/clover-rococo.d.ts +3 -0
  519. package/services/chain-service/helper/api-helper/spec/clover-rococo.js +61 -0
  520. package/services/chain-service/helper/api-helper/spec/clover.d.ts +3 -0
  521. package/services/chain-service/helper/api-helper/spec/clover.js +27 -0
  522. package/services/chain-service/helper/api-helper/spec/coinversation.d.ts +3 -0
  523. package/services/chain-service/helper/api-helper/spec/coinversation.js +17 -0
  524. package/services/chain-service/helper/api-helper/spec/competitors-club.d.ts +3 -0
  525. package/services/chain-service/helper/api-helper/spec/competitors-club.js +77 -0
  526. package/services/chain-service/helper/api-helper/spec/crab.d.ts +2 -0
  527. package/services/chain-service/helper/api-helper/spec/crab.js +5 -0
  528. package/services/chain-service/helper/api-helper/spec/crown-sterling.d.ts +3 -0
  529. package/services/chain-service/helper/api-helper/spec/crown-sterling.js +48 -0
  530. package/services/chain-service/helper/api-helper/spec/crust.d.ts +3 -0
  531. package/services/chain-service/helper/api-helper/spec/crust.js +5 -0
  532. package/services/chain-service/helper/api-helper/spec/cumulus-test-parachain.d.ts +3 -0
  533. package/services/chain-service/helper/api-helper/spec/cumulus-test-parachain.js +17 -0
  534. package/services/chain-service/helper/api-helper/spec/darwinia.d.ts +2 -0
  535. package/services/chain-service/helper/api-helper/spec/darwinia.js +5 -0
  536. package/services/chain-service/helper/api-helper/spec/datahighway.d.ts +3 -0
  537. package/services/chain-service/helper/api-helper/spec/datahighway.js +233 -0
  538. package/services/chain-service/helper/api-helper/spec/dock-mainnet.d.ts +3 -0
  539. package/services/chain-service/helper/api-helper/spec/dock-mainnet.js +9 -0
  540. package/services/chain-service/helper/api-helper/spec/dock-testnet.d.ts +3 -0
  541. package/services/chain-service/helper/api-helper/spec/dock-testnet.js +9 -0
  542. package/services/chain-service/helper/api-helper/spec/dolphin.d.ts +3 -0
  543. package/services/chain-service/helper/api-helper/spec/dolphin.js +22 -0
  544. package/services/chain-service/helper/api-helper/spec/dotmog.d.ts +3 -0
  545. package/services/chain-service/helper/api-helper/spec/dotmog.js +58 -0
  546. package/services/chain-service/helper/api-helper/spec/eave.d.ts +3 -0
  547. package/services/chain-service/helper/api-helper/spec/eave.js +409 -0
  548. package/services/chain-service/helper/api-helper/spec/edgeware.d.ts +3 -0
  549. package/services/chain-service/helper/api-helper/spec/edgeware.js +7 -0
  550. package/services/chain-service/helper/api-helper/spec/encointer-node-notee.d.ts +3 -0
  551. package/services/chain-service/helper/api-helper/spec/encointer-node-notee.js +68 -0
  552. package/services/chain-service/helper/api-helper/spec/encointer-node-teeproxy.d.ts +3 -0
  553. package/services/chain-service/helper/api-helper/spec/encointer-node-teeproxy.js +45 -0
  554. package/services/chain-service/helper/api-helper/spec/encointer-para.d.ts +3 -0
  555. package/services/chain-service/helper/api-helper/spec/encointer-para.js +72 -0
  556. package/services/chain-service/helper/api-helper/spec/equilibrium.d.ts +8 -0
  557. package/services/chain-service/helper/api-helper/spec/equilibrium.js +97 -0
  558. package/services/chain-service/helper/api-helper/spec/fantour.d.ts +3 -0
  559. package/services/chain-service/helper/api-helper/spec/fantour.js +63 -0
  560. package/services/chain-service/helper/api-helper/spec/galital-parachain.d.ts +3 -0
  561. package/services/chain-service/helper/api-helper/spec/galital-parachain.js +58 -0
  562. package/services/chain-service/helper/api-helper/spec/galital.d.ts +3 -0
  563. package/services/chain-service/helper/api-helper/spec/galital.js +63 -0
  564. package/services/chain-service/helper/api-helper/spec/galois.d.ts +3 -0
  565. package/services/chain-service/helper/api-helper/spec/galois.js +47 -0
  566. package/services/chain-service/helper/api-helper/spec/gamepower.d.ts +3 -0
  567. package/services/chain-service/helper/api-helper/spec/gamepower.js +64 -0
  568. package/services/chain-service/helper/api-helper/spec/genshiro.d.ts +3 -0
  569. package/services/chain-service/helper/api-helper/spec/genshiro.js +24 -0
  570. package/services/chain-service/helper/api-helper/spec/hanonycash.d.ts +3 -0
  571. package/services/chain-service/helper/api-helper/spec/hanonycash.js +26 -0
  572. package/services/chain-service/helper/api-helper/spec/hydrate.d.ts +3 -0
  573. package/services/chain-service/helper/api-helper/spec/hydrate.js +52 -0
  574. package/services/chain-service/helper/api-helper/spec/idavoll.d.ts +3 -0
  575. package/services/chain-service/helper/api-helper/spec/idavoll.js +17 -0
  576. package/services/chain-service/helper/api-helper/spec/index.d.ts +3 -0
  577. package/services/chain-service/helper/api-helper/spec/index.js +264 -0
  578. package/services/chain-service/helper/api-helper/spec/integritee.d.ts +3 -0
  579. package/services/chain-service/helper/api-helper/spec/integritee.js +28 -0
  580. package/services/chain-service/helper/api-helper/spec/interbtc.d.ts +7 -0
  581. package/services/chain-service/helper/api-helper/spec/interbtc.js +50 -0
  582. package/services/chain-service/helper/api-helper/spec/ipse.d.ts +3 -0
  583. package/services/chain-service/helper/api-helper/spec/ipse.js +106 -0
  584. package/services/chain-service/helper/api-helper/spec/jupiter-rococo.d.ts +3 -0
  585. package/services/chain-service/helper/api-helper/spec/jupiter-rococo.js +17 -0
  586. package/services/chain-service/helper/api-helper/spec/jupiter.d.ts +3 -0
  587. package/services/chain-service/helper/api-helper/spec/jupiter.js +63 -0
  588. package/services/chain-service/helper/api-helper/spec/khala.d.ts +3 -0
  589. package/services/chain-service/helper/api-helper/spec/khala.js +5 -0
  590. package/services/chain-service/helper/api-helper/spec/kilt.d.ts +3 -0
  591. package/services/chain-service/helper/api-helper/spec/kilt.js +5 -0
  592. package/services/chain-service/helper/api-helper/spec/konomi.d.ts +3 -0
  593. package/services/chain-service/helper/api-helper/spec/konomi.js +17 -0
  594. package/services/chain-service/helper/api-helper/spec/kpron.d.ts +3 -0
  595. package/services/chain-service/helper/api-helper/spec/kpron.js +17 -0
  596. package/services/chain-service/helper/api-helper/spec/kulupu.d.ts +3 -0
  597. package/services/chain-service/helper/api-helper/spec/kulupu.js +57 -0
  598. package/services/chain-service/helper/api-helper/spec/kusari.d.ts +3 -0
  599. package/services/chain-service/helper/api-helper/spec/kusari.js +38 -0
  600. package/services/chain-service/helper/api-helper/spec/kylin.d.ts +3 -0
  601. package/services/chain-service/helper/api-helper/spec/kylin.js +29 -0
  602. package/services/chain-service/helper/api-helper/spec/laminar.d.ts +3 -0
  603. package/services/chain-service/helper/api-helper/spec/laminar.js +5 -0
  604. package/services/chain-service/helper/api-helper/spec/litentry.d.ts +3 -0
  605. package/services/chain-service/helper/api-helper/spec/litentry.js +17 -0
  606. package/services/chain-service/helper/api-helper/spec/mangata.d.ts +3 -0
  607. package/services/chain-service/helper/api-helper/spec/mangata.js +13 -0
  608. package/services/chain-service/helper/api-helper/spec/manta.d.ts +3 -0
  609. package/services/chain-service/helper/api-helper/spec/manta.js +22 -0
  610. package/services/chain-service/helper/api-helper/spec/mathchain.d.ts +3 -0
  611. package/services/chain-service/helper/api-helper/spec/mathchain.js +47 -0
  612. package/services/chain-service/helper/api-helper/spec/moonbeam.d.ts +2 -0
  613. package/services/chain-service/helper/api-helper/spec/moonbeam.js +5 -0
  614. package/services/chain-service/helper/api-helper/spec/moonsama-development.d.ts +3 -0
  615. package/services/chain-service/helper/api-helper/spec/moonsama-development.js +17 -0
  616. package/services/chain-service/helper/api-helper/spec/mybank.d.ts +3 -0
  617. package/services/chain-service/helper/api-helper/spec/mybank.js +80 -0
  618. package/services/chain-service/helper/api-helper/spec/neatcoin.d.ts +3 -0
  619. package/services/chain-service/helper/api-helper/spec/neatcoin.js +25 -0
  620. package/services/chain-service/helper/api-helper/spec/neumann.d.ts +3 -0
  621. package/services/chain-service/helper/api-helper/spec/neumann.js +48 -0
  622. package/services/chain-service/helper/api-helper/spec/nftmart.d.ts +3 -0
  623. package/services/chain-service/helper/api-helper/spec/nftmart.js +127 -0
  624. package/services/chain-service/helper/api-helper/spec/nodle.d.ts +3 -0
  625. package/services/chain-service/helper/api-helper/spec/nodle.js +46 -0
  626. package/services/chain-service/helper/api-helper/spec/opal.d.ts +3 -0
  627. package/services/chain-service/helper/api-helper/spec/opal.js +9 -0
  628. package/services/chain-service/helper/api-helper/spec/opportunity.d.ts +3 -0
  629. package/services/chain-service/helper/api-helper/spec/opportunity.js +5 -0
  630. package/services/chain-service/helper/api-helper/spec/origintrail.d.ts +5 -0
  631. package/services/chain-service/helper/api-helper/spec/origintrail.js +198 -0
  632. package/services/chain-service/helper/api-helper/spec/pangolin.d.ts +2 -0
  633. package/services/chain-service/helper/api-helper/spec/pangolin.js +5 -0
  634. package/services/chain-service/helper/api-helper/spec/pangoro.d.ts +2 -0
  635. package/services/chain-service/helper/api-helper/spec/pangoro.js +7 -0
  636. package/services/chain-service/helper/api-helper/spec/parallel.d.ts +14 -0
  637. package/services/chain-service/helper/api-helper/spec/parallel.js +5 -0
  638. package/services/chain-service/helper/api-helper/spec/parami.d.ts +3 -0
  639. package/services/chain-service/helper/api-helper/spec/parami.js +14 -0
  640. package/services/chain-service/helper/api-helper/spec/phoenix.d.ts +3 -0
  641. package/services/chain-service/helper/api-helper/spec/phoenix.js +45 -0
  642. package/services/chain-service/helper/api-helper/spec/pichiu.d.ts +3 -0
  643. package/services/chain-service/helper/api-helper/spec/pichiu.js +29 -0
  644. package/services/chain-service/helper/api-helper/spec/plasm.d.ts +3 -0
  645. package/services/chain-service/helper/api-helper/spec/plasm.js +47 -0
  646. package/services/chain-service/helper/api-helper/spec/polkadex.d.ts +3 -0
  647. package/services/chain-service/helper/api-helper/spec/polkadex.js +25 -0
  648. package/services/chain-service/helper/api-helper/spec/polkafoundry.d.ts +3 -0
  649. package/services/chain-service/helper/api-helper/spec/polkafoundry.js +36 -0
  650. package/services/chain-service/helper/api-helper/spec/polymesh.d.ts +3 -0
  651. package/services/chain-service/helper/api-helper/spec/polymesh.js +13 -0
  652. package/services/chain-service/helper/api-helper/spec/pontem.d.ts +2 -0
  653. package/services/chain-service/helper/api-helper/spec/pontem.js +5 -0
  654. package/services/chain-service/helper/api-helper/spec/prism.d.ts +3 -0
  655. package/services/chain-service/helper/api-helper/spec/prism.js +17 -0
  656. package/services/chain-service/helper/api-helper/spec/quartz.d.ts +3 -0
  657. package/services/chain-service/helper/api-helper/spec/quartz.js +9 -0
  658. package/services/chain-service/helper/api-helper/spec/realis.d.ts +3 -0
  659. package/services/chain-service/helper/api-helper/spec/realis.js +35 -0
  660. package/services/chain-service/helper/api-helper/spec/riochain.d.ts +3 -0
  661. package/services/chain-service/helper/api-helper/spec/riochain.js +97 -0
  662. package/services/chain-service/helper/api-helper/spec/robonomics.d.ts +3 -0
  663. package/services/chain-service/helper/api-helper/spec/robonomics.js +34 -0
  664. package/services/chain-service/helper/api-helper/spec/shibuya.d.ts +3 -0
  665. package/services/chain-service/helper/api-helper/spec/shibuya.js +47 -0
  666. package/services/chain-service/helper/api-helper/spec/shiden.d.ts +3 -0
  667. package/services/chain-service/helper/api-helper/spec/shiden.js +47 -0
  668. package/services/chain-service/helper/api-helper/spec/snowbridge.d.ts +2 -0
  669. package/services/chain-service/helper/api-helper/spec/snowbridge.js +5 -0
  670. package/services/chain-service/helper/api-helper/spec/soraSubstrate.d.ts +3 -0
  671. package/services/chain-service/helper/api-helper/spec/soraSubstrate.js +5 -0
  672. package/services/chain-service/helper/api-helper/spec/spanner.d.ts +3 -0
  673. package/services/chain-service/helper/api-helper/spec/spanner.js +494 -0
  674. package/services/chain-service/helper/api-helper/spec/stafi.d.ts +3 -0
  675. package/services/chain-service/helper/api-helper/spec/stafi.js +18 -0
  676. package/services/chain-service/helper/api-helper/spec/standard.d.ts +3 -0
  677. package/services/chain-service/helper/api-helper/spec/standard.js +5 -0
  678. package/services/chain-service/helper/api-helper/spec/subdao.d.ts +3 -0
  679. package/services/chain-service/helper/api-helper/spec/subdao.js +14 -0
  680. package/services/chain-service/helper/api-helper/spec/subgame.d.ts +3 -0
  681. package/services/chain-service/helper/api-helper/spec/subgame.js +178 -0
  682. package/services/chain-service/helper/api-helper/spec/subsocial.d.ts +2 -0
  683. package/services/chain-service/helper/api-helper/spec/subsocial.js +8 -0
  684. package/services/chain-service/helper/api-helper/spec/subspace.d.ts +0 -0
  685. package/services/chain-service/helper/api-helper/spec/subspace.js +126 -0
  686. package/services/chain-service/helper/api-helper/spec/substrateContractsNode.d.ts +3 -0
  687. package/services/chain-service/helper/api-helper/spec/substrateContractsNode.js +16 -0
  688. package/services/chain-service/helper/api-helper/spec/swapdex.d.ts +3 -0
  689. package/services/chain-service/helper/api-helper/spec/swapdex.js +38 -0
  690. package/services/chain-service/helper/api-helper/spec/ternoa.d.ts +3 -0
  691. package/services/chain-service/helper/api-helper/spec/ternoa.js +88 -0
  692. package/services/chain-service/helper/api-helper/spec/trustbase.d.ts +3 -0
  693. package/services/chain-service/helper/api-helper/spec/trustbase.js +17 -0
  694. package/services/chain-service/helper/api-helper/spec/uart.d.ts +3 -0
  695. package/services/chain-service/helper/api-helper/spec/uart.js +282 -0
  696. package/services/chain-service/helper/api-helper/spec/unique.d.ts +3 -0
  697. package/services/chain-service/helper/api-helper/spec/unique.js +117 -0
  698. package/services/chain-service/helper/api-helper/spec/unitv.d.ts +3 -0
  699. package/services/chain-service/helper/api-helper/spec/unitv.js +18 -0
  700. package/services/chain-service/helper/api-helper/spec/vln-rococo.d.ts +3 -0
  701. package/services/chain-service/helper/api-helper/spec/vln-rococo.js +102 -0
  702. package/services/chain-service/helper/api-helper/spec/vln.d.ts +3 -0
  703. package/services/chain-service/helper/api-helper/spec/vln.js +38 -0
  704. package/services/chain-service/helper/api-helper/spec/vodka.d.ts +3 -0
  705. package/services/chain-service/helper/api-helper/spec/vodka.js +15 -0
  706. package/services/chain-service/helper/api-helper/spec/web3games.d.ts +3 -0
  707. package/services/chain-service/helper/api-helper/spec/web3games.js +36 -0
  708. package/services/chain-service/helper/api-helper/spec/westlake.d.ts +3 -0
  709. package/services/chain-service/helper/api-helper/spec/westlake.js +298 -0
  710. package/services/chain-service/helper/api-helper/spec/zCloak.d.ts +3 -0
  711. package/services/chain-service/helper/api-helper/spec/zCloak.js +39 -0
  712. package/services/chain-service/helper/api-helper/spec/zeitgeist.d.ts +3 -0
  713. package/services/chain-service/helper/api-helper/spec/zeitgeist.js +24 -0
  714. package/services/chain-service/helper/api-helper/spec/zenlink.d.ts +3 -0
  715. package/services/chain-service/helper/api-helper/spec/zenlink.js +50 -0
  716. package/services/chain-service/helper/api-helper/spec/zero.d.ts +3 -0
  717. package/services/chain-service/helper/api-helper/spec/zero.js +5 -0
  718. package/services/chain-service/helper/api-helper/util.d.ts +5 -0
  719. package/services/chain-service/helper/api-helper/util.js +15 -0
  720. package/services/chain-service/helper/erc20_abi.json +224 -0
  721. package/services/chain-service/helper/erc721_abi.json +384 -0
  722. package/services/chain-service/helper/index.d.ts +5 -0
  723. package/services/chain-service/helper/index.js +13 -0
  724. package/services/chain-service/helper/psp22_abi.json +967 -0
  725. package/services/chain-service/helper/psp34_abi.json +1988 -0
  726. package/services/chain-service/helper/test_erc721_abi.json +393 -0
  727. package/services/chain-service/index.d.ts +102 -0
  728. package/services/chain-service/index.js +1139 -0
  729. package/services/chain-service/types.d.ts +110 -0
  730. package/services/chain-service/types.js +17 -0
  731. package/services/chain-service/utils.d.ts +64 -0
  732. package/services/chain-service/utils.js +321 -0
  733. package/services/history-service/index.d.ts +22 -0
  734. package/services/history-service/index.js +102 -0
  735. package/services/history-service/subsquid-multi-chain-history.d.ts +30 -0
  736. package/services/history-service/subsquid-multi-chain-history.js +251 -0
  737. package/services/migration-service/Base.d.ts +8 -0
  738. package/services/migration-service/Base.js +13 -0
  739. package/services/migration-service/index.d.ts +7 -0
  740. package/services/migration-service/index.js +37 -0
  741. package/services/migration-service/scripts/ClearOldStorage.d.ts +4 -0
  742. package/services/migration-service/scripts/ClearOldStorage.js +11 -0
  743. package/services/migration-service/scripts/MigrateImportedToken.d.ts +4 -0
  744. package/services/migration-service/scripts/MigrateImportedToken.js +40 -0
  745. package/services/migration-service/scripts/MigrateNetworkSettings.d.ts +4 -0
  746. package/services/migration-service/scripts/MigrateNetworkSettings.js +30 -0
  747. package/services/migration-service/scripts/index.d.ts +3 -0
  748. package/services/migration-service/scripts/index.js +10 -0
  749. package/services/notification-service/NotificationService.d.ts +8 -0
  750. package/services/notification-service/NotificationService.js +46 -0
  751. package/services/price-service/coingecko.d.ts +2 -0
  752. package/services/price-service/coingecko.js +31 -0
  753. package/services/price-service/index.d.ts +16 -0
  754. package/services/price-service/index.js +71 -0
  755. package/services/request-service/constants.d.ts +1 -0
  756. package/services/request-service/constants.js +4 -0
  757. package/services/request-service/handler/AuthRequestHandler.d.ts +29 -0
  758. package/services/request-service/handler/AuthRequestHandler.js +253 -0
  759. package/services/request-service/handler/EvmRequestHandler.d.ts +19 -0
  760. package/services/request-service/handler/EvmRequestHandler.js +207 -0
  761. package/services/request-service/handler/MetadataRequestHandler.d.ts +18 -0
  762. package/services/request-service/handler/MetadataRequestHandler.js +75 -0
  763. package/services/request-service/handler/PopupHandler.d.ts +9 -0
  764. package/services/request-service/handler/PopupHandler.js +79 -0
  765. package/services/request-service/handler/SubstrateRequestHandler.d.ts +17 -0
  766. package/services/request-service/handler/SubstrateRequestHandler.js +94 -0
  767. package/services/request-service/helper/index.d.ts +4 -0
  768. package/services/request-service/helper/index.js +67 -0
  769. package/services/request-service/index.d.ts +46 -0
  770. package/services/request-service/index.js +147 -0
  771. package/services/request-service/types.d.ts +25 -0
  772. package/services/request-service/types.js +1 -0
  773. package/services/setting-service/SettingService.d.ts +8 -0
  774. package/services/setting-service/SettingService.js +31 -0
  775. package/services/setting-service/constants.d.ts +3 -0
  776. package/services/setting-service/constants.js +6 -0
  777. package/services/storage-service/DatabaseService.d.ts +64 -0
  778. package/services/storage-service/DatabaseService.js +219 -0
  779. package/services/storage-service/databases/index.d.ts +45 -0
  780. package/services/storage-service/databases/index.js +37 -0
  781. package/services/storage-service/db-stores/Asset.d.ts +6 -0
  782. package/services/storage-service/db-stores/Asset.js +12 -0
  783. package/services/storage-service/db-stores/Balance.d.ts +7 -0
  784. package/services/storage-service/db-stores/Balance.js +24 -0
  785. package/services/storage-service/db-stores/BaseStore.d.ts +11 -0
  786. package/services/storage-service/db-stores/BaseStore.js +22 -0
  787. package/services/storage-service/db-stores/BaseStoreWithAddress.d.ts +5 -0
  788. package/services/storage-service/db-stores/BaseStoreWithAddress.js +20 -0
  789. package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.d.ts +7 -0
  790. package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +25 -0
  791. package/services/storage-service/db-stores/BaseStoreWithChain.d.ts +5 -0
  792. package/services/storage-service/db-stores/BaseStoreWithChain.js +12 -0
  793. package/services/storage-service/db-stores/Chain.d.ts +6 -0
  794. package/services/storage-service/db-stores/Chain.js +12 -0
  795. package/services/storage-service/db-stores/ChainStakingMetadata.d.ts +9 -0
  796. package/services/storage-service/db-stores/ChainStakingMetadata.js +29 -0
  797. package/services/storage-service/db-stores/Crowdloan.d.ts +6 -0
  798. package/services/storage-service/db-stores/Crowdloan.js +15 -0
  799. package/services/storage-service/db-stores/Migration.d.ts +4 -0
  800. package/services/storage-service/db-stores/Migration.js +5 -0
  801. package/services/storage-service/db-stores/Nft.d.ts +12 -0
  802. package/services/storage-service/db-stores/Nft.js +61 -0
  803. package/services/storage-service/db-stores/NftCollection.d.ts +7 -0
  804. package/services/storage-service/db-stores/NftCollection.js +22 -0
  805. package/services/storage-service/db-stores/NominatorMetadata.d.ts +9 -0
  806. package/services/storage-service/db-stores/NominatorMetadata.js +22 -0
  807. package/services/storage-service/db-stores/Price.d.ts +4 -0
  808. package/services/storage-service/db-stores/Price.js +5 -0
  809. package/services/storage-service/db-stores/Staking.d.ts +9 -0
  810. package/services/storage-service/db-stores/Staking.js +29 -0
  811. package/services/storage-service/db-stores/Transaction.d.ts +12 -0
  812. package/services/storage-service/db-stores/Transaction.js +41 -0
  813. package/services/storage-service/db-stores/index.d.ts +10 -0
  814. package/services/storage-service/db-stores/index.js +13 -0
  815. package/services/transaction-service/event-parser/index.d.ts +5 -0
  816. package/services/transaction-service/event-parser/index.js +96 -0
  817. package/services/transaction-service/helpers/index.d.ts +5 -0
  818. package/services/transaction-service/helpers/index.js +14 -0
  819. package/services/transaction-service/index.d.ts +44 -0
  820. package/services/transaction-service/index.js +693 -0
  821. package/services/transaction-service/types.d.ts +48 -0
  822. package/services/transaction-service/types.js +1 -0
  823. package/services/transaction-service/utils.d.ts +4 -0
  824. package/services/transaction-service/utils.js +25 -0
  825. package/signers/substrates/KeyringSigner.d.ts +1 -1
  826. package/stores/AccountRef.d.ts +5 -0
  827. package/stores/AccountRef.js +10 -0
  828. package/stores/Accounts.d.ts +1 -1
  829. package/stores/Application.d.ts +7 -0
  830. package/stores/Application.js +20 -0
  831. package/stores/AssetSetting.d.ts +5 -0
  832. package/stores/AssetSetting.js +12 -0
  833. package/stores/Authorize.d.ts +5 -0
  834. package/stores/Authorize.js +10 -0
  835. package/stores/CurrentAccountStore.d.ts +5 -0
  836. package/stores/CurrentAccountStore.js +10 -0
  837. package/stores/Keyring.d.ts +7 -0
  838. package/stores/Keyring.js +32 -0
  839. package/stores/Settings.d.ts +5 -0
  840. package/stores/Settings.js +10 -0
  841. package/stores/SubscribableStore.d.ts +9 -0
  842. package/stores/SubscribableStore.js +25 -0
  843. package/stores/TransactionHistory.d.ts +6 -0
  844. package/stores/TransactionHistory.js +29 -0
  845. package/stores/TransactionHistoryV2.d.ts +5 -0
  846. package/stores/TransactionHistoryV2.js +10 -0
  847. package/stores/TransactionHistoryV3.d.ts +5 -0
  848. package/stores/TransactionHistoryV3.js +10 -0
  849. package/stores/index.d.ts +1 -0
  850. package/stores/index.js +2 -1
  851. package/utils/address.d.ts +1 -0
  852. package/utils/address.js +10 -0
  853. package/utils/eth/mergeTransactionAndSignature.d.ts +2 -0
  854. package/utils/eth/mergeTransactionAndSignature.js +14 -0
  855. package/utils/eth/parseTransaction/base.d.ts +17 -0
  856. package/utils/eth/parseTransaction/base.js +273 -0
  857. package/utils/eth/parseTransaction/index.d.ts +6 -0
  858. package/utils/eth/parseTransaction/index.js +220 -0
  859. package/utils/eth.d.ts +18 -0
  860. package/utils/eth.js +64 -0
  861. package/utils/index.d.ts +37 -0
  862. package/utils/index.js +273 -2
  863. package/utils/keyring.d.ts +4 -0
  864. package/utils/keyring.js +49 -0
  865. package/utils/request.d.ts +1 -0
  866. package/utils/request.js +7 -0
  867. package/errors/SubWalletProviderError.d.ts +0 -6
@@ -0,0 +1,693 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { EvmProviderError } from '@subwallet/extension-base/background/errors/EvmProviderError';
5
+ import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
6
+ import { BasicTxErrorType, BasicTxWarningCode, ChainType, EvmProviderErrorType, ExtrinsicStatus, ExtrinsicType, NotificationType, TransactionDirection } from '@subwallet/extension-base/background/KoniTypes';
7
+ import { TransactionWarning } from '@subwallet/extension-base/background/warnings/TransactionWarning';
8
+ import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
9
+ import { _getChainNativeTokenBasicInfo, _getEvmChainId } from '@subwallet/extension-base/services/chain-service/utils';
10
+ import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
11
+ import { parseTransferEventLogs, parseXcmEventLogs } from '@subwallet/extension-base/services/transaction-service/event-parser';
12
+ import { getTransactionId, isSubstrateTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
13
+ import { getTransactionLink, parseTransactionData } from '@subwallet/extension-base/services/transaction-service/utils';
14
+ import { anyNumberToBN } from '@subwallet/extension-base/utils/eth';
15
+ import { parseTxAndSignature } from '@subwallet/extension-base/utils/eth/mergeTransactionAndSignature';
16
+ import { isContractAddress, parseContractInput } from '@subwallet/extension-base/utils/eth/parseTransaction';
17
+ import keyring from '@subwallet/ui-keyring';
18
+ import EventEmitter from 'eventemitter3';
19
+ import RLP from 'rlp';
20
+ import { BehaviorSubject } from 'rxjs';
21
+ import { u8aToHex } from '@polkadot/util';
22
+ export default class TransactionService {
23
+ transactionSubject = new BehaviorSubject({});
24
+ get transactions() {
25
+ return this.transactionSubject.getValue();
26
+ }
27
+ constructor(chainService, requestService, balanceService, historyService, notificationService, databaseService) {
28
+ this.chainService = chainService;
29
+ this.requestService = requestService;
30
+ this.balanceService = balanceService;
31
+ this.historyService = historyService;
32
+ this.notificationService = notificationService;
33
+ this.databaseService = databaseService;
34
+ }
35
+ get allTransactions() {
36
+ return Object.values(this.transactions);
37
+ }
38
+ get processingTransactions() {
39
+ return this.allTransactions.filter(t => t.status === ExtrinsicStatus.PENDING || t.status === ExtrinsicStatus.PROCESSING);
40
+ }
41
+ getTransaction(id) {
42
+ return this.transactions[id];
43
+ }
44
+ checkDuplicate(transaction) {
45
+ // Check duplicated transaction
46
+ const existed = this.processingTransactions.filter(item => item.address === transaction.address && item.chain === transaction.chain);
47
+ if (existed.length > 0) {
48
+ return [new TransactionError(BasicTxErrorType.DUPLICATE_TRANSACTION)];
49
+ }
50
+ return [];
51
+ }
52
+ async generalValidate(validationInput) {
53
+ const validation = {
54
+ ...validationInput,
55
+ errors: validationInput.errors || [],
56
+ warnings: validationInput.warnings || []
57
+ };
58
+ const {
59
+ additionalValidator,
60
+ address,
61
+ chain,
62
+ edAsWarning,
63
+ isTransferAll,
64
+ transaction
65
+ } = validation;
66
+
67
+ // Check duplicate transaction
68
+ validation.errors.push(...this.checkDuplicate(validationInput));
69
+
70
+ // Return unsupported error if not found transaction
71
+ if (!transaction) {
72
+ validation.errors.push(new TransactionError(BasicTxErrorType.UNSUPPORTED));
73
+ }
74
+ const validationResponse = {
75
+ status: undefined,
76
+ ...validation
77
+ };
78
+
79
+ // Estimate fee
80
+ const estimateFee = {
81
+ symbol: '',
82
+ decimals: 0,
83
+ value: ''
84
+ };
85
+ const chainInfo = this.chainService.getChainInfoByKey(chain);
86
+ if (!chainInfo) {
87
+ validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, "Can't find network"));
88
+ } else {
89
+ const {
90
+ decimals,
91
+ symbol
92
+ } = _getChainNativeTokenBasicInfo(chainInfo);
93
+ estimateFee.decimals = decimals;
94
+ estimateFee.symbol = symbol;
95
+ if (transaction) {
96
+ try {
97
+ if (isSubstrateTransaction(transaction)) {
98
+ estimateFee.value = (await transaction.paymentInfo(address)).partialFee.toString();
99
+ } else {
100
+ const web3 = this.chainService.getEvmApi(chain);
101
+ if (!web3) {
102
+ validationResponse.errors.push(new TransactionError(BasicTxErrorType.CHAIN_DISCONNECTED));
103
+ } else {
104
+ const gasPrice = await web3.api.eth.getGasPrice();
105
+ const gasLimit = await web3.api.eth.estimateGas(transaction);
106
+ estimateFee.value = (gasLimit * parseInt(gasPrice)).toString();
107
+ }
108
+ }
109
+ } catch (e) {
110
+ estimateFee.value = '0';
111
+ }
112
+ }
113
+ }
114
+ validationResponse.estimateFee = estimateFee;
115
+
116
+ // Read-only account
117
+ const pair = keyring.getPair(address);
118
+ if (!pair) {
119
+ validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, 'Can\'t find account'));
120
+ } else {
121
+ var _pair$meta;
122
+ if ((_pair$meta = pair.meta) !== null && _pair$meta !== void 0 && _pair$meta.isReadOnly) {
123
+ validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, 'This is read-only account'));
124
+ }
125
+ }
126
+
127
+ // Balance
128
+ const transferNative = validationResponse.transferNativeAmount || '0';
129
+ const nativeTokenInfo = this.chainService.getNativeTokenInfo(chain);
130
+ const balance = await this.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
131
+ const existentialDeposit = nativeTokenInfo.minAmount || '0';
132
+ const feeNum = parseInt(estimateFee.value);
133
+ const balanceNum = parseInt(balance.value);
134
+ const edNum = parseInt(existentialDeposit);
135
+ const transferNativeNum = parseInt(transferNative);
136
+ if (!isTransferAll) {
137
+ if (transferNativeNum + feeNum > balanceNum) {
138
+ validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
139
+ } else {
140
+ if (balanceNum - (transferNativeNum + feeNum) <= edNum) {
141
+ if (edAsWarning) {
142
+ validationResponse.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT, ''));
143
+ } else {
144
+ validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT, ''));
145
+ }
146
+ }
147
+ }
148
+ }
149
+
150
+ // Validate transaction with additionalValidator method
151
+ additionalValidator && (await additionalValidator(validationResponse));
152
+ return validationResponse;
153
+ }
154
+ getTransactionSubject() {
155
+ return this.transactionSubject;
156
+ }
157
+ fillTransactionDefaultInfo(transaction) {
158
+ const isInternal = !transaction.url;
159
+ return {
160
+ ...transaction,
161
+ createdAt: new Date(),
162
+ updatedAt: new Date(),
163
+ errors: transaction.errors || [],
164
+ warnings: transaction.warnings || [],
165
+ url: transaction.url || EXTENSION_REQUEST_URL,
166
+ status: ExtrinsicStatus.PENDING,
167
+ isInternal,
168
+ id: getTransactionId(transaction.chainType, transaction.chain, isInternal),
169
+ extrinsicHash: ''
170
+ };
171
+ }
172
+ async addTransaction(inputTransaction) {
173
+ const transactions = this.transactions;
174
+ // Fill transaction default info
175
+ const transaction = this.fillTransactionDefaultInfo(inputTransaction);
176
+
177
+ // Add Transaction
178
+ transactions[transaction.id] = transaction;
179
+ this.transactionSubject.next({
180
+ ...transactions
181
+ });
182
+ console.log(transaction);
183
+
184
+ // Send transaction
185
+ return await this.sendTransaction(transaction);
186
+ }
187
+ generateBeforeHandleResponseErrors(errors) {
188
+ return {
189
+ errors,
190
+ additionalValidator: undefined,
191
+ address: '',
192
+ chain: '',
193
+ chainType: ChainType.SUBSTRATE,
194
+ data: undefined,
195
+ extrinsicType: ExtrinsicType.UNKNOWN,
196
+ transferNativeAmount: undefined,
197
+ url: undefined,
198
+ warnings: []
199
+ };
200
+ }
201
+ async handleTransaction(transaction) {
202
+ const validatedTransaction = await this.generalValidate(transaction);
203
+ const stopByErrors = validatedTransaction.errors.length > 0;
204
+ const stopByWarnings = validatedTransaction.warnings.length > 0 && !validatedTransaction.ignoreWarnings;
205
+ if (stopByErrors || stopByWarnings) {
206
+ return validatedTransaction;
207
+ }
208
+ validatedTransaction.warnings = [];
209
+ const emitter = await this.addTransaction(validatedTransaction);
210
+ await new Promise(resolve => {
211
+ emitter.on('extrinsicHash', data => {
212
+ validatedTransaction.extrinsicHash = data.extrinsicHash;
213
+ resolve();
214
+ });
215
+ emitter.on('error', data => {
216
+ if (data.errors.length > 0) {
217
+ validatedTransaction.errors.push(...data.errors);
218
+ resolve();
219
+ }
220
+ });
221
+ });
222
+ return validatedTransaction;
223
+ }
224
+ async sendTransaction(transaction) {
225
+ // Send Transaction
226
+ const emitter = transaction.chainType === 'substrate' ? this.signAndSendSubstrateTransaction(transaction) : await this.signAndSendEvmTransaction(transaction);
227
+ emitter.on('extrinsicHash', data => {
228
+ this.onHasTransactionHash(data);
229
+ });
230
+ emitter.on('success', data => {
231
+ this.handlePostProcessing(data.id);
232
+ this.onSuccess(data);
233
+ });
234
+ emitter.on('error', data => {
235
+ // this.handlePostProcessing(data.id); // might enable this later
236
+ this.onFailed({
237
+ ...data,
238
+ errors: [...data.errors, new TransactionError(BasicTxErrorType.INTERNAL_ERROR)]
239
+ });
240
+ });
241
+
242
+ // Todo: handle any event with transaction.eventsHandler
243
+
244
+ return emitter;
245
+ }
246
+ removeTransaction(id) {
247
+ if (this.transactions[id]) {
248
+ delete this.transactions[id];
249
+ this.transactionSubject.next({
250
+ ...this.transactions
251
+ });
252
+ }
253
+ }
254
+ updateTransaction(id, data) {
255
+ const transaction = this.transactions[id];
256
+ if (transaction) {
257
+ this.transactions[id] = {
258
+ ...transaction,
259
+ ...data
260
+ };
261
+ }
262
+ }
263
+ getTransactionLink(id) {
264
+ const transaction = this.getTransaction(id);
265
+ const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
266
+ return getTransactionLink(chainInfo, transaction.extrinsicHash);
267
+ }
268
+ transactionToHistory(id, eventLogs) {
269
+ const transaction = this.getTransaction(id);
270
+ const historyItem = {
271
+ chain: transaction.chain,
272
+ direction: TransactionDirection.SEND,
273
+ type: transaction.extrinsicType,
274
+ from: transaction.address,
275
+ to: '',
276
+ chainType: transaction.chainType,
277
+ address: transaction.address,
278
+ status: ExtrinsicStatus.PROCESSING,
279
+ extrinsicHash: transaction.extrinsicHash,
280
+ time: transaction.createdAt.getTime(),
281
+ fee: transaction.estimateFee,
282
+ blockNumber: 0,
283
+ // TODO: to be added later
284
+ blockHash: '' // TODO: to be added later
285
+ };
286
+
287
+ const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
288
+ const nativeAsset = _getChainNativeTokenBasicInfo(chainInfo);
289
+ const baseNativeAmount = {
290
+ value: '0',
291
+ decimals: nativeAsset.decimals,
292
+ symbol: nativeAsset.symbol
293
+ };
294
+
295
+ // Fill data by extrinsicType
296
+ switch (transaction.extrinsicType) {
297
+ case ExtrinsicType.TRANSFER_BALANCE:
298
+ {
299
+ const inputData = parseTransactionData(transaction.data);
300
+ historyItem.to = inputData.to;
301
+ const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
302
+ historyItem.amount = {
303
+ value: inputData.value || '0',
304
+ decimals: sendingTokenInfo.decimals || 0,
305
+ symbol: sendingTokenInfo.symbol
306
+ };
307
+ eventLogs && parseTransferEventLogs(historyItem, eventLogs, transaction.chain, sendingTokenInfo, chainInfo);
308
+ }
309
+ break;
310
+ case ExtrinsicType.TRANSFER_TOKEN:
311
+ {
312
+ const inputData = parseTransactionData(transaction.data);
313
+ historyItem.to = inputData.to;
314
+ const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
315
+ historyItem.amount = {
316
+ value: inputData.value || '0',
317
+ decimals: sendingTokenInfo.decimals || 0,
318
+ symbol: sendingTokenInfo.symbol
319
+ };
320
+ eventLogs && parseTransferEventLogs(historyItem, eventLogs, transaction.chain, sendingTokenInfo, chainInfo);
321
+ }
322
+ break;
323
+ case ExtrinsicType.TRANSFER_XCM:
324
+ {
325
+ const inputData = parseTransactionData(transaction.data);
326
+ historyItem.to = inputData.to;
327
+ const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
328
+ historyItem.amount = {
329
+ value: inputData.value || '0',
330
+ decimals: sendingTokenInfo.decimals || 0,
331
+ symbol: sendingTokenInfo.symbol
332
+ };
333
+ eventLogs && parseXcmEventLogs(historyItem, eventLogs, transaction.chain, sendingTokenInfo, chainInfo);
334
+ }
335
+ break;
336
+ case ExtrinsicType.SEND_NFT:
337
+ {
338
+ const inputData = parseTransactionData(transaction.data);
339
+ historyItem.to = inputData.recipientAddress;
340
+ historyItem.amount = {
341
+ decimals: 0,
342
+ symbol: 'NFT',
343
+ value: '1'
344
+ };
345
+ }
346
+ break;
347
+ case ExtrinsicType.STAKING_BOND:
348
+ {
349
+ const data = parseTransactionData(transaction.data);
350
+ historyItem.amount = {
351
+ ...baseNativeAmount,
352
+ value: data.amount || '0'
353
+ };
354
+ }
355
+ break;
356
+ case ExtrinsicType.STAKING_JOIN_POOL:
357
+ {
358
+ const data = parseTransactionData(transaction.data);
359
+ historyItem.amount = {
360
+ ...baseNativeAmount,
361
+ value: data.amount || '0'
362
+ };
363
+ historyItem.to = data.selectedPool.name || data.selectedPool.id.toString();
364
+ }
365
+ break;
366
+ case ExtrinsicType.STAKING_UNBOND:
367
+ {
368
+ const data = parseTransactionData(transaction.data);
369
+ historyItem.to = data.validatorAddress || '';
370
+ historyItem.amount = {
371
+ ...baseNativeAmount,
372
+ value: data.amount || '0'
373
+ };
374
+ }
375
+ break;
376
+ case ExtrinsicType.STAKING_LEAVE_POOL:
377
+ {
378
+ const data = parseTransactionData(transaction.data);
379
+ historyItem.to = data.nominatorMetadata.address || '';
380
+ historyItem.amount = {
381
+ ...baseNativeAmount,
382
+ value: data.amount || '0'
383
+ };
384
+ }
385
+ break;
386
+ case ExtrinsicType.STAKING_CLAIM_REWARD:
387
+ {
388
+ const data = parseTransactionData(transaction.data);
389
+ historyItem.amount = {
390
+ ...baseNativeAmount,
391
+ value: data.unclaimedReward || '0'
392
+ };
393
+ }
394
+ break;
395
+ case ExtrinsicType.STAKING_WITHDRAW:
396
+ {
397
+ const data = parseTransactionData(transaction.data);
398
+ historyItem.to = data.validatorAddress || '';
399
+ }
400
+ break;
401
+ case ExtrinsicType.EVM_EXECUTE:
402
+ // Todo: Update historyItem.to
403
+ break;
404
+ case ExtrinsicType.UNKNOWN:
405
+ break;
406
+ }
407
+ return historyItem;
408
+ }
409
+ onHasTransactionHash({
410
+ eventLogs,
411
+ extrinsicHash,
412
+ id
413
+ }) {
414
+ // Write processing transaction history
415
+ this.updateTransaction(id, {
416
+ extrinsicHash,
417
+ status: ExtrinsicStatus.PROCESSING
418
+ });
419
+ this.historyService.insertHistory(this.transactionToHistory(id, eventLogs)).catch(console.error);
420
+ console.log(`Transaction "${id}" is submitted with hash ${extrinsicHash || ''}`);
421
+ }
422
+ handlePostProcessing(id) {
423
+ // must be done after success/failure to make sure the transaction is finalized
424
+ const transaction = this.getTransaction(id);
425
+ switch (transaction.extrinsicType) {
426
+ case ExtrinsicType.SEND_NFT:
427
+ {
428
+ const inputData = parseTransactionData(transaction.data);
429
+ const sender = keyring.getAccount(inputData.senderAddress);
430
+ const recipient = keyring.getAccount(inputData.recipientAddress);
431
+ sender && this.databaseService.handleNftTransfer(transaction.chain, [sender.address, ALL_ACCOUNT_KEY], inputData.nftItem).catch(console.error);
432
+ recipient && this.databaseService.addNft(recipient.address, {
433
+ ...inputData.nftItem,
434
+ owner: recipient.address
435
+ }).catch(console.error);
436
+ }
437
+ }
438
+ }
439
+ onSuccess({
440
+ blockHash,
441
+ blockNumber,
442
+ id
443
+ }) {
444
+ const transaction = this.getTransaction(id);
445
+ this.updateTransaction(id, {
446
+ status: ExtrinsicStatus.SUCCESS
447
+ });
448
+ console.log('Transaction completed', id, transaction.extrinsicHash);
449
+
450
+ // Write success transaction history
451
+ this.historyService.updateHistory(transaction.chain, transaction.extrinsicHash, {
452
+ status: ExtrinsicStatus.SUCCESS,
453
+ blockNumber: blockNumber || 0,
454
+ blockHash: blockHash || ''
455
+ }).catch(console.error);
456
+ this.notificationService.notify({
457
+ type: NotificationType.SUCCESS,
458
+ title: 'Transaction completed',
459
+ message: `Transaction ${transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash} completed`,
460
+ action: {
461
+ url: this.getTransactionLink(id)
462
+ },
463
+ notifyViaBrowser: true
464
+ });
465
+ }
466
+ onFailed({
467
+ blockHash,
468
+ blockNumber,
469
+ errors,
470
+ id
471
+ }) {
472
+ const transaction = this.getTransaction(id);
473
+ if (transaction) {
474
+ this.updateTransaction(id, {
475
+ status: ExtrinsicStatus.FAIL,
476
+ errors
477
+ });
478
+ console.log('Transaction failed', id, transaction.extrinsicHash);
479
+
480
+ // Write failed transaction history
481
+ this.historyService.updateHistory(transaction.chain, transaction.extrinsicHash, {
482
+ status: ExtrinsicStatus.FAIL,
483
+ blockNumber: blockNumber || 0,
484
+ blockHash: blockHash || ''
485
+ }).catch(console.error);
486
+ this.notificationService.notify({
487
+ type: NotificationType.ERROR,
488
+ title: 'Transaction failed',
489
+ message: `Transaction ${transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash} failed`,
490
+ action: {
491
+ url: this.getTransactionLink(id)
492
+ },
493
+ notifyViaBrowser: true
494
+ });
495
+ }
496
+
497
+ // Log transaction errors
498
+ console.error(errors);
499
+ }
500
+ generateHashPayload(chain, transaction) {
501
+ const chainInfo = this.chainService.getChainInfoByKey(chain);
502
+ const txObject = {
503
+ nonce: transaction.nonce || 1,
504
+ from: transaction.from,
505
+ gasPrice: anyNumberToBN(transaction.gasPrice).toNumber(),
506
+ gasLimit: anyNumberToBN(transaction.gas).toNumber(),
507
+ to: transaction.to !== undefined ? transaction.to : '',
508
+ value: anyNumberToBN(transaction.value).toNumber(),
509
+ data: transaction.data ? transaction.data : '',
510
+ chainId: _getEvmChainId(chainInfo)
511
+ };
512
+ const data = [txObject.nonce, txObject.gasPrice, txObject.gasLimit, txObject.to, txObject.value, txObject.data, txObject.chainId, new Uint8Array([0x00]), new Uint8Array([0x00])];
513
+ const encoded = RLP.encode(data);
514
+ return u8aToHex(encoded);
515
+ }
516
+ async signAndSendEvmTransaction({
517
+ address,
518
+ chain,
519
+ id,
520
+ transaction,
521
+ url
522
+ }) {
523
+ const payload = transaction;
524
+ const evmApi = this.chainService.getEvmApi(chain);
525
+ const chainInfo = this.chainService.getChainInfoByKey(chain);
526
+ const accountPair = keyring.getPair(address);
527
+ const account = {
528
+ address,
529
+ ...accountPair.meta
530
+ };
531
+ if (!payload.account) {
532
+ payload.account = account;
533
+ }
534
+
535
+ // Allow sign transaction
536
+ payload.canSign = true;
537
+
538
+ // Fill contract info
539
+ if (!payload.parseData) {
540
+ const isToContract = await isContractAddress(payload.to || '', evmApi);
541
+ payload.isToContract = isToContract;
542
+ payload.parseData = isToContract ? payload.data ? (await parseContractInput(payload.data || '', payload.to || '', chainInfo)).result : '' : payload.data || '';
543
+ }
544
+
545
+ // Set unique nonce to avoid transaction errors
546
+ if (!payload.nonce) {
547
+ const evmApi = this.chainService.getEvmApi(chain);
548
+ payload.nonce = await evmApi.api.eth.getTransactionCount(address);
549
+ }
550
+ if (!payload.chainId) {
551
+ var _chainInfo$evmInfo$ev, _chainInfo$evmInfo;
552
+ payload.chainId = (_chainInfo$evmInfo$ev = (_chainInfo$evmInfo = chainInfo.evmInfo) === null || _chainInfo$evmInfo === void 0 ? void 0 : _chainInfo$evmInfo.evmChainId) !== null && _chainInfo$evmInfo$ev !== void 0 ? _chainInfo$evmInfo$ev : 1;
553
+ }
554
+
555
+ // Autofill from
556
+ if (!payload.from) {
557
+ payload.from = address;
558
+ }
559
+ const isExternal = !!account.isExternal;
560
+
561
+ // generate hashPayload for EVM transaction
562
+ payload.hashPayload = this.generateHashPayload(chain, payload);
563
+ const emitter = new EventEmitter();
564
+ const txObject = {
565
+ nonce: payload.nonce || 1,
566
+ from: payload.from,
567
+ gasPrice: anyNumberToBN(payload.gasPrice).toNumber(),
568
+ gasLimit: anyNumberToBN(payload.gas).toNumber(),
569
+ to: payload.to !== undefined ? payload.to : '',
570
+ value: anyNumberToBN(payload.value).toNumber(),
571
+ data: payload.data ? payload.data : '',
572
+ chainId: payload.chainId
573
+ };
574
+ const eventData = {
575
+ id,
576
+ errors: [],
577
+ warnings: []
578
+ };
579
+ this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(({
580
+ isApproved,
581
+ payload
582
+ }) => {
583
+ if (isApproved) {
584
+ let signedTransaction;
585
+ if (!payload) {
586
+ throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
587
+ }
588
+ const web3Api = this.chainService.getEvmApi(chain).api;
589
+ if (!isExternal) {
590
+ signedTransaction = payload;
591
+ } else {
592
+ const signed = parseTxAndSignature(txObject, payload);
593
+ const recover = web3Api.eth.accounts.recoverTransaction(signed);
594
+ if (recover.toLowerCase() !== account.address.toLowerCase()) {
595
+ throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
596
+ }
597
+ signedTransaction = signed;
598
+ }
599
+ signedTransaction && web3Api.eth.sendSignedTransaction(signedTransaction).once('transactionHash', hash => {
600
+ eventData.extrinsicHash = hash;
601
+ emitter.emit('extrinsicHash', eventData);
602
+ }).once('receipt', rs => {
603
+ eventData.blockHash = rs.blockHash;
604
+ eventData.blockNumber = rs.blockNumber;
605
+ emitter.emit('success', eventData);
606
+ }).once('error', e => {
607
+ eventData.errors.push(new TransactionError(BasicTxErrorType.SEND_TRANSACTION_FAILED, e.message));
608
+ emitter.emit('error', eventData);
609
+ }).catch(e => {
610
+ eventData.errors.push(new TransactionError(BasicTxErrorType.UNABLE_TO_SEND, e.message));
611
+ emitter.emit('error', eventData);
612
+ });
613
+ } else {
614
+ this.removeTransaction(id);
615
+ eventData.errors.push(new TransactionError(BasicTxErrorType.USER_REJECT_REQUEST));
616
+ emitter.emit('error', eventData);
617
+ }
618
+ }).catch(e => {
619
+ this.removeTransaction(id);
620
+ eventData.errors.push(new TransactionError(BasicTxErrorType.UNABLE_TO_SIGN, e.message));
621
+ emitter.emit('error', eventData);
622
+ });
623
+ return emitter;
624
+ }
625
+ signAndSendSubstrateTransaction({
626
+ address,
627
+ id,
628
+ transaction,
629
+ url
630
+ }) {
631
+ const emitter = new EventEmitter();
632
+ const eventData = {
633
+ id,
634
+ errors: [],
635
+ warnings: []
636
+ };
637
+ console.debug(address, transaction);
638
+ transaction.signAsync(address, {
639
+ signer: {
640
+ signPayload: async payload => {
641
+ const signing = await this.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
642
+ return {
643
+ id: new Date().getTime(),
644
+ signature: signing.signature
645
+ };
646
+ }
647
+ }
648
+ }).then(rs => {
649
+ rs.send(txState => {
650
+ // handle events, logs, history
651
+ if (!txState || !txState.status) {
652
+ return;
653
+ }
654
+ if (txState.status.isInBlock) {
655
+ eventData.eventLogs = txState.events;
656
+ if (!eventData.extrinsicHash || eventData.extrinsicHash === '') {
657
+ eventData.extrinsicHash = txState.txHash.toHex();
658
+ emitter.emit('extrinsicHash', eventData);
659
+ }
660
+ }
661
+ if (txState.status.isFinalized) {
662
+ eventData.eventLogs = txState.events;
663
+ // TODO: push block hash and block number into eventData
664
+ txState.events.filter(({
665
+ event: {
666
+ section
667
+ }
668
+ }) => section === 'system').forEach(({
669
+ event: {
670
+ method,
671
+ data: [error]
672
+ }
673
+ }) => {
674
+ if (method === 'ExtrinsicFailed') {
675
+ eventData.errors.push(new TransactionError(BasicTxErrorType.SEND_TRANSACTION_FAILED, error.toString()));
676
+ emitter.emit('error', eventData);
677
+ } else if (method === 'ExtrinsicSuccess') {
678
+ emitter.emit('success', eventData);
679
+ }
680
+ });
681
+ }
682
+ }).catch(e => {
683
+ eventData.errors.push(new TransactionError(BasicTxErrorType.SEND_TRANSACTION_FAILED, e.message));
684
+ emitter.emit('error', eventData);
685
+ });
686
+ }).catch(e => {
687
+ this.removeTransaction(id);
688
+ eventData.errors.push(new TransactionError(BasicTxErrorType.UNABLE_TO_SIGN, e.message));
689
+ emitter.emit('error', eventData);
690
+ });
691
+ return emitter;
692
+ }
693
+ }