carbon-js-sdk 0.3.30 → 0.3.32

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 (100) hide show
  1. package/README.md +1 -1
  2. package/lib/CarbonSDK.js +0 -5
  3. package/lib/clients/CarbonQueryClient.js +2 -2
  4. package/lib/clients/ETHClient.js +15 -15
  5. package/lib/clients/HydrogenClient.js +1 -1
  6. package/lib/clients/NEOClient.js +7 -7
  7. package/lib/clients/ZILClient.js +16 -16
  8. package/lib/codec/bank/event.d.ts +12 -0
  9. package/lib/codec/bank/event.js +74 -1
  10. package/lib/codec/bank/query.d.ts +48 -0
  11. package/lib/codec/bank/query.js +250 -1
  12. package/lib/codec/book/query.d.ts +26 -0
  13. package/lib/codec/book/query.js +140 -1
  14. package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
  15. package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
  16. package/lib/codec/cosmos/tx/v1beta1/tx.js +2 -2
  17. package/lib/codec/headersync/consensus_peers.d.ts +26 -0
  18. package/lib/codec/headersync/consensus_peers.js +166 -1
  19. package/lib/codec/headersync/export.d.ts +1 -1
  20. package/lib/codec/headersync/export.js +3 -1
  21. package/lib/codec/headersync/genesis.d.ts +3 -3
  22. package/lib/codec/headersync/genesis.js +8 -8
  23. package/lib/codec/headersync/query.d.ts +2 -2
  24. package/lib/codec/headersync/query.js +14 -12
  25. package/lib/codec/ibc/applications/fee/v1/ack.d.ts +24 -0
  26. package/lib/codec/ibc/applications/fee/v1/ack.js +125 -0
  27. package/lib/codec/ibc/applications/fee/v1/fee.d.ts +68 -0
  28. package/lib/codec/ibc/applications/fee/v1/fee.js +289 -0
  29. package/lib/codec/ibc/applications/fee/v1/genesis.d.ts +93 -0
  30. package/lib/codec/ibc/applications/fee/v1/genesis.js +390 -0
  31. package/lib/codec/ibc/applications/fee/v1/metadata.d.ts +25 -0
  32. package/lib/codec/ibc/applications/fee/v1/metadata.js +71 -0
  33. package/lib/codec/ibc/applications/fee/v1/query.d.ts +312 -0
  34. package/lib/codec/ibc/applications/fee/v1/query.js +1187 -0
  35. package/lib/codec/ibc/applications/fee/v1/tx.d.ts +171 -0
  36. package/lib/codec/ibc/applications/fee/v1/tx.js +524 -0
  37. package/lib/codec/ibc/applications/interchain_accounts/controller/v1/tx.d.ts +78 -0
  38. package/lib/codec/ibc/applications/interchain_accounts/controller/v1/tx.js +296 -0
  39. package/lib/codec/ibc/applications/interchain_accounts/genesis/v1/genesis.d.ts +80 -0
  40. package/lib/codec/ibc/applications/interchain_accounts/genesis/v1/genesis.js +439 -0
  41. package/lib/codec/index.d.ts +8 -3
  42. package/lib/codec/index.js +418 -397
  43. package/lib/codec/misc/query.d.ts +16 -2
  44. package/lib/codec/misc/query.js +120 -22
  45. package/lib/codec/sequence/genesis.d.ts +30 -0
  46. package/lib/codec/sequence/genesis.js +122 -0
  47. package/lib/codec/sequence/query.d.ts +63 -0
  48. package/lib/codec/sequence/query.js +208 -0
  49. package/lib/codec/sequence/tx.d.ts +41 -0
  50. package/lib/codec/sequence/tx.js +148 -0
  51. package/lib/constant/generic.d.ts +6 -1
  52. package/lib/constant/generic.js +7 -3
  53. package/lib/constant/ibc.d.ts +1 -5
  54. package/lib/constant/ibc.js +95 -94
  55. package/lib/constant/token.d.ts +1 -0
  56. package/lib/constant/token.js +2 -1
  57. package/lib/modules/cdp.js +43 -43
  58. package/lib/modules/gov.js +14 -14
  59. package/lib/modules/liquiditypool.js +1 -1
  60. package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
  61. package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
  62. package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
  63. package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
  64. package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
  65. package/lib/provider/amino/types/admin.js +30 -30
  66. package/lib/provider/amino/types/bank.js +1 -1
  67. package/lib/provider/amino/types/broker.js +1 -1
  68. package/lib/provider/amino/types/cdp.js +22 -22
  69. package/lib/provider/amino/types/coin.js +2 -2
  70. package/lib/provider/amino/types/gov.js +4 -4
  71. package/lib/provider/amino/types/ibc.js +1 -1
  72. package/lib/provider/amino/types/leverage.js +1 -1
  73. package/lib/provider/amino/types/liquidityPool.js +7 -7
  74. package/lib/provider/amino/types/market.js +1 -1
  75. package/lib/provider/amino/types/oracle.js +1 -1
  76. package/lib/provider/amino/types/order.js +4 -4
  77. package/lib/provider/amino/types/position.js +1 -1
  78. package/lib/provider/amino/types/profile.js +1 -1
  79. package/lib/provider/amino/types/staking.js +4 -4
  80. package/lib/provider/amino/types/subaccount.js +3 -3
  81. package/lib/provider/amino/utils.js +11 -11
  82. package/lib/provider/keplr/KeplrAccount.d.ts +6 -11
  83. package/lib/provider/keplr/KeplrAccount.js +15 -9
  84. package/lib/provider/leap/LeapAccount.d.ts +6 -11
  85. package/lib/provider/leap/LeapAccount.js +14 -8
  86. package/lib/provider/ledger/ledger.js +2 -2
  87. package/lib/provider/metamask/MetaMask.js +1 -1
  88. package/lib/provider/o3/O3Wallet.js +2 -2
  89. package/lib/util/address.js +13 -13
  90. package/lib/util/api.js +4 -4
  91. package/lib/util/fetch.js +1 -1
  92. package/lib/util/generic.js +3 -3
  93. package/lib/util/number.js +5 -5
  94. package/lib/util/tx.d.ts +2 -0
  95. package/lib/wallet/CarbonSigner.js +2 -2
  96. package/lib/wallet/CarbonSigningClient.js +8 -8
  97. package/lib/wallet/CarbonWallet.js +6 -6
  98. package/lib/websocket/connector.js +3 -3
  99. package/lib/websocket/models.d.ts +1 -2
  100. package/package.json +8 -7
package/README.md CHANGED
@@ -68,7 +68,7 @@ Install `buf` if you have not:
68
68
 
69
69
  Run script to generate codec:
70
70
  ```bash
71
- make gen-proto
71
+ make gen-codecs
72
72
  ```
73
73
 
74
74
  The tar file will be generated at `<Carbon Project>/gen/proto-ts.tar.gz`. You can copy that file to `<Carbon SDK Project>/proto-ts.tar.gz` and proceed with above `sync-proto` step.
package/lib/CarbonSDK.js CHANGED
@@ -106,11 +106,6 @@ class CarbonSDK {
106
106
  blockchain: blockchain_1.Blockchain.BinanceSmartChain,
107
107
  tokenClient: this.token,
108
108
  });
109
- this.arbitrum = clients_1.ETHClient.instance({
110
- configProvider: this,
111
- blockchain: blockchain_1.Blockchain.Arbitrum,
112
- tokenClient: this.token,
113
- });
114
109
  this.zil = clients_1.ZILClient.instance({
115
110
  configProvider: this,
116
111
  blockchain: blockchain_1.Blockchain.Zilliqa,
@@ -44,7 +44,7 @@ class CarbonQueryClient {
44
44
  constructor(tmClient) {
45
45
  this.tmClient = tmClient;
46
46
  this.baseClient = new stargate_1.QueryClient(this.tmClient);
47
- const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
47
+ const rpcClient = (0, stargate_1.createProtobufRpcClient)(this.baseClient);
48
48
  this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
49
49
  this.adl = new query_1.QueryClientImpl(rpcClient);
50
50
  this.book = new query_2.QueryClientImpl(rpcClient);
@@ -85,7 +85,7 @@ class CarbonQueryClient {
85
85
  };
86
86
  }
87
87
  getProtobufRpcClient() {
88
- return stargate_1.createProtobufRpcClient(this.baseClient);
88
+ return (0, stargate_1.createProtobufRpcClient)(this.baseClient);
89
89
  }
90
90
  }
91
91
  exports.default = CarbonQueryClient;
@@ -40,13 +40,13 @@ class ETHClient {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
41
  const tokenQueryResults = yield api.token.getAllTokens();
42
42
  const lockProxyAddress = this.getLockProxyAddress().toLowerCase();
43
- const tokens = tokenQueryResults.filter((token) => blockchain_1.blockchainForChainId(token.chainId.toNumber()) == this.blockchain &&
43
+ const tokens = tokenQueryResults.filter((token) => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) == this.blockchain &&
44
44
  token.tokenAddress.length == 40 &&
45
- token.bridgeAddress.toLowerCase() == generic_1.stripHexPrefix(lockProxyAddress) &&
45
+ token.bridgeAddress.toLowerCase() == (0, generic_1.stripHexPrefix)(lockProxyAddress) &&
46
46
  (!whitelistDenoms || whitelistDenoms.includes(token.denom)) &&
47
- this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress)));
47
+ this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress)));
48
48
  const assetIds = tokens.map((token) => {
49
- return this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
49
+ return this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress));
50
50
  });
51
51
  const provider = this.getProvider();
52
52
  const contractAddress = this.getBalanceReaderAddress();
@@ -95,14 +95,14 @@ class ETHClient {
95
95
  throw new Error("Invalid recovery address");
96
96
  }
97
97
  const fromTokenId = fromToken.id;
98
- const fromTokenAddress = generic_1.appendHexPrefix(fromToken.tokenAddress);
98
+ const fromTokenAddress = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
99
99
  const toTokenDenom = toToken.denom;
100
100
  const recoveryAddressHex = ethers_1.ethers.utils.hexlify(util_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, CarbonSDK_1.default.Network.MainNet));
101
101
  const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
102
102
  const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
103
103
  const nonce = yield rpcProvider.getTransactionCount(fromAddress);
104
104
  const contract = new ethers_1.ethers.Contract(this.getBridgeEntranceAddr(), eth_1.ABIs.bridgeEntrance, rpcProvider);
105
- const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
105
+ const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
106
106
  const tokenCreator = fromToken.creator;
107
107
  const targetAddressBytes = util_1.AddressUtils.SWTHAddress.getAddressBytes(tokenCreator, CarbonSDK_1.default.Network.MainNet);
108
108
  const targetProxyHash = ethers_1.ethers.utils.hexlify(targetAddressBytes);
@@ -137,9 +137,9 @@ class ETHClient {
137
137
  throw new Error("Minimum gas required: 150,000");
138
138
  }
139
139
  const networkConfig = this.getNetworkConfig();
140
- const assetId = generic_1.appendHexPrefix(token.tokenAddress);
141
- const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
142
- const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
140
+ const assetId = (0, generic_1.appendHexPrefix)(token.tokenAddress);
141
+ const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(token));
142
+ const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
143
143
  const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
144
144
  const swthAddress = ethers_1.ethers.utils.hexlify(address);
145
145
  const contractAddress = this.getLockProxyAddress();
@@ -190,16 +190,16 @@ class ETHClient {
190
190
  return "insufficient balance";
191
191
  }
192
192
  const networkConfig = this.getNetworkConfig();
193
- const assetId = generic_1.appendHexPrefix(tokenWithExternalBalances.tokenAddress);
194
- const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(tokenWithExternalBalances));
195
- const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
193
+ const assetId = (0, generic_1.appendHexPrefix)(tokenWithExternalBalances.tokenAddress);
194
+ const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(tokenWithExternalBalances));
195
+ const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
196
196
  const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(tokenWithExternalBalances.id));
197
197
  const nonce = Math.floor(Math.random() * 1000000000); // random nonce to prevent replay attacks
198
198
  const message = ethers_1.ethers.utils.solidityKeccak256(["string", "address", "bytes", "bytes", "bytes", "uint256", "uint256", "uint256"], ["sendTokens", assetId, targetProxyHash, toAssetHash, feeAddress, amount, feeAmount, nonce]);
199
199
  // logger("sendDeposit message", message)
200
200
  let signatureResult;
201
201
  const { address, signature } = yield getSignatureCallback(message);
202
- const signatureBytes = ethers_1.ethers.utils.arrayify(generic_1.appendHexPrefix(signature));
202
+ const signatureBytes = ethers_1.ethers.utils.arrayify((0, generic_1.appendHexPrefix)(signature));
203
203
  const rsv = ethers_1.ethers.utils.splitSignature(signatureBytes);
204
204
  // logger("sign result", address, signature)
205
205
  signatureResult = {
@@ -238,7 +238,7 @@ class ETHClient {
238
238
  if (!feeInfo.deposit_fee) {
239
239
  throw new Error("unsupported token");
240
240
  }
241
- if (blockchain_1.blockchainForChainId(token.chainId.toNumber()) !== this.blockchain) {
241
+ if ((0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) !== this.blockchain) {
242
242
  throw new Error("unsupported token");
243
243
  }
244
244
  let feeAmount = ethers_1.ethers.BigNumber.from(feeInfo.deposit_fee);
@@ -304,7 +304,7 @@ class ETHClient {
304
304
  getTargetProxyHash(token) {
305
305
  const networkConfig = this.getNetworkConfig();
306
306
  const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
307
- const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
307
+ const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
308
308
  return addressHex;
309
309
  }
310
310
  getProvider() {
@@ -29,7 +29,7 @@ exports.HydrogenEndpoints = {
29
29
  const formatDateField = (value) => {
30
30
  if (typeof value !== "string")
31
31
  return null;
32
- return dayjs_1.default(value);
32
+ return (0, dayjs_1.default)(value);
33
33
  };
34
34
  const formatCrossChainTransfer = (value) => {
35
35
  var _a, _b;
@@ -64,13 +64,13 @@ class NEOClient {
64
64
  return __awaiter(this, void 0, void 0, function* () {
65
65
  const tokenQueryResults = yield sdk.token.getAllTokens();
66
66
  const account = new Neon.wallet.Account(address);
67
- const tokens = tokenQueryResults.filter(token => blockchain_1.blockchainForChainId(token.chainId.toNumber()) == this.blockchain &&
67
+ const tokens = tokenQueryResults.filter(token => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) == this.blockchain &&
68
68
  token.tokenAddress.length == 40 &&
69
69
  token.bridgeAddress.length == 40);
70
70
  const client = new Neon.rpc.RPCClient(url, "2.5.2"); // TODO: should we change the RPC version??
71
71
  // NOTE: fetching of tokens is chunked in sets of 15 as we may hit
72
72
  // the gas limit on the RPC node and error out otherwise
73
- const promises = lodash_1.chunk(tokens, 75).map((partition) => __awaiter(this, void 0, void 0, function* () {
73
+ const promises = (0, lodash_1.chunk)(tokens, 75).map((partition) => __awaiter(this, void 0, void 0, function* () {
74
74
  var _a, _b, _c;
75
75
  let acc = {};
76
76
  for (const token of partition) {
@@ -111,8 +111,8 @@ class NEOClient {
111
111
  const targetProxyHash = this.getTargetProxyHash(token);
112
112
  const toAssetHash = Neon.u.str2hexstring(token.id);
113
113
  const addressBytes = address_1.SWTHAddress.getAddressBytes(swthAddress, networkConfig.network);
114
- const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
115
- const zeroAddressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(constant_1.ZeroAddress));
114
+ const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
115
+ const zeroAddressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(constant_1.ZeroAddress));
116
116
  const amount = ethers_1.ethers.BigNumber.from(token.externalBalance);
117
117
  const feeAmount = ethers_1.ethers.BigNumber.from(feeAmountInput !== null && feeAmountInput !== void 0 ? feeAmountInput : "100000000");
118
118
  const feeAddress = feeAmount.isZero() ? zeroAddressHex : networkConfig.feeAddress;
@@ -159,7 +159,7 @@ class NEOClient {
159
159
  const fromAddress = util_1.AddressUtils.NEOAddress.publicKeyToAddress(publicKeyOutput.publicKey);
160
160
  const targetProxyHash = this.getTargetProxyHash(token);
161
161
  const toAssetHash = Neon.u.str2hexstring(token.id);
162
- const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
162
+ const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
163
163
  const nonce = Math.floor(Math.random() * 1000000);
164
164
  if (amount.lt(feeAmount)) {
165
165
  throw new Error("Invalid amount");
@@ -195,7 +195,7 @@ class NEOClient {
195
195
  const fromAddress = ledger.scriptHash;
196
196
  const targetProxyHash = this.getTargetProxyHash(token);
197
197
  const toAssetHash = Neon.u.str2hexstring(token.id);
198
- const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
198
+ const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
199
199
  const feeAddress = networkConfig.feeAddress;
200
200
  const nonce = Math.floor(Math.random() * 1000000);
201
201
  if (amount.lt(feeAmount)) {
@@ -315,7 +315,7 @@ class NEOClient {
315
315
  getTargetProxyHash(token) {
316
316
  const networkConfig = this.getNetworkConfig();
317
317
  const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
318
- const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
318
+ const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
319
319
  return addressHex;
320
320
  }
321
321
  getNetworkConfig() {
@@ -74,10 +74,10 @@ class ZILClient {
74
74
  getExternalBalances(sdk, address, whitelistDenoms) {
75
75
  return __awaiter(this, void 0, void 0, function* () {
76
76
  const tokenQueryResults = yield sdk.token.getAllTokens();
77
- const tokens = tokenQueryResults.filter(token => blockchain_1.blockchainForChainId(token.chainId.toNumber()) == this.blockchain &&
77
+ const tokens = tokenQueryResults.filter(token => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) == this.blockchain &&
78
78
  token.tokenAddress.length == 40 &&
79
79
  (!whitelistDenoms || whitelistDenoms.includes(token.denom)));
80
- const requests = tokens.map(token => token.tokenAddress === zeroAddress ? exports.balanceBatchRequest(address.replace(/^0x/i, "")) : exports.tokenBalanceBatchRequest(token.tokenAddress, address));
80
+ const requests = tokens.map(token => token.tokenAddress === zeroAddress ? (0, exports.balanceBatchRequest)(address.replace(/^0x/i, "")) : (0, exports.tokenBalanceBatchRequest)(token.tokenAddress, address));
81
81
  const response = yield fetch(this.getProviderUrl(), {
82
82
  method: "post",
83
83
  headers: { "content-type": "application/json" },
@@ -102,7 +102,7 @@ class ZILClient {
102
102
  // if (!isValidAddress) {
103
103
  // throw new Error("invalid address")
104
104
  // }
105
- return zilliqa_1.fromBech32Address(bech32Address).toLowerCase().substr(2);
105
+ return (0, zilliqa_1.fromBech32Address)(bech32Address).toLowerCase().substr(2);
106
106
  });
107
107
  }
108
108
  // see examplesV2/zil_client.ts on how to confirm the transactions
@@ -148,7 +148,7 @@ class ZILClient {
148
148
  zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
149
149
  }
150
150
  const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
151
- const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(zilAddress));
151
+ const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(zilAddress));
152
152
  if (balanceAndNonceResp.error !== undefined) {
153
153
  throw new Error(balanceAndNonceResp.error.message);
154
154
  }
@@ -166,7 +166,7 @@ class ZILClient {
166
166
  vname: 'spender',
167
167
  type: 'ByStr20',
168
168
  // TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
169
- value: spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : generic_1.appendHexPrefix(token.bridgeAddress),
169
+ value: spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : (0, generic_1.appendHexPrefix)(token.bridgeAddress),
170
170
  },
171
171
  {
172
172
  vname: 'amount',
@@ -184,7 +184,7 @@ class ZILClient {
184
184
  }
185
185
  checkAllowanceZRC2(token, owner, spender) {
186
186
  return __awaiter(this, void 0, void 0, function* () {
187
- const contractAddress = generic_1.appendHexPrefix(token.tokenAddress);
187
+ const contractAddress = (0, generic_1.appendHexPrefix)(token.tokenAddress);
188
188
  const zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
189
189
  const resp = yield zilliqa.blockchain.getSmartContractSubState(contractAddress, "allowances", [owner, spender]);
190
190
  if (resp.error !== undefined) {
@@ -204,13 +204,13 @@ class ZILClient {
204
204
  throw new Error("Invalid recovery address");
205
205
  }
206
206
  const fromTokenId = fromToken.id;
207
- const fromTokenAddr = generic_1.appendHexPrefix(fromToken.tokenAddress);
207
+ const fromTokenAddr = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
208
208
  const toTokenDenom = toToken.denom;
209
- const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(fromToken));
209
+ const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(fromToken));
210
210
  const recoveryAddressHex = ethers_1.ethers.utils.hexlify(index_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, CarbonSDK_1.default.Network.MainNet));
211
211
  const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
212
212
  const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
213
- const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
213
+ const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
214
214
  const contractAddress = this.getBridgeEntranceAddr();
215
215
  let zilliqa;
216
216
  if (typeof signer === 'string') {
@@ -225,7 +225,7 @@ class ZILClient {
225
225
  zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
226
226
  }
227
227
  const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
228
- const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(fromAddress));
228
+ const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(fromAddress));
229
229
  if (balanceAndNonceResp.error !== undefined) {
230
230
  throw new Error(balanceAndNonceResp.error.message);
231
231
  }
@@ -302,13 +302,13 @@ class ZILClient {
302
302
  return __awaiter(this, void 0, void 0, function* () {
303
303
  const { address, amount, token, gasPrice, gasLimit, zilAddress, signer } = params;
304
304
  const networkConfig = this.getNetworkConfig();
305
- const assetId = generic_1.appendHexPrefix(token.tokenAddress);
306
- const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
307
- const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
305
+ const assetId = (0, generic_1.appendHexPrefix)(token.tokenAddress);
306
+ const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(token));
307
+ const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
308
308
  const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
309
309
  const swthAddress = ethers_1.ethers.utils.hexlify(address);
310
310
  // TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
311
- const contractAddress = generic_1.appendHexPrefix(token.bridgeAddress);
311
+ const contractAddress = (0, generic_1.appendHexPrefix)(token.bridgeAddress);
312
312
  let zilliqa;
313
313
  if (typeof signer === 'string') {
314
314
  zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
@@ -322,7 +322,7 @@ class ZILClient {
322
322
  zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
323
323
  }
324
324
  const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
325
- const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(zilAddress));
325
+ const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(zilAddress));
326
326
  if (balanceAndNonceResp.error !== undefined) {
327
327
  throw new Error(balanceAndNonceResp.error.message);
328
328
  }
@@ -407,7 +407,7 @@ class ZILClient {
407
407
  getTargetProxyHash(token) {
408
408
  const networkConfig = this.getNetworkConfig();
409
409
  const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
410
- const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
410
+ const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
411
411
  return addressHex;
412
412
  }
413
413
  getNetworkConfig() {
@@ -10,6 +10,11 @@ export interface CoinReceived {
10
10
  receiver: string;
11
11
  amount: Coin[];
12
12
  }
13
+ export interface CoinSent {
14
+ sender: string;
15
+ receiver: string;
16
+ amount: Coin[];
17
+ }
13
18
  export declare const CoinSpent: {
14
19
  encode(message: CoinSpent, writer?: _m0.Writer): _m0.Writer;
15
20
  decode(input: _m0.Reader | Uint8Array, length?: number | undefined): CoinSpent;
@@ -24,6 +29,13 @@ export declare const CoinReceived: {
24
29
  toJSON(message: CoinReceived): unknown;
25
30
  fromPartial(object: DeepPartial<CoinReceived>): CoinReceived;
26
31
  };
32
+ export declare const CoinSent: {
33
+ encode(message: CoinSent, writer?: _m0.Writer): _m0.Writer;
34
+ decode(input: _m0.Reader | Uint8Array, length?: number | undefined): CoinSent;
35
+ fromJSON(object: any): CoinSent;
36
+ toJSON(message: CoinSent): unknown;
37
+ fromPartial(object: DeepPartial<CoinSent>): CoinSent;
38
+ };
27
39
  declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
28
40
  export declare type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
29
41
  [K in keyof T]?: DeepPartial<T[K]>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CoinReceived = exports.CoinSpent = exports.protobufPackage = void 0;
6
+ exports.CoinSent = exports.CoinReceived = exports.CoinSpent = exports.protobufPackage = void 0;
7
7
  /* eslint-disable */
8
8
  const long_1 = __importDefault(require("long"));
9
9
  const minimal_1 = __importDefault(require("protobufjs/minimal"));
@@ -131,6 +131,79 @@ exports.CoinReceived = {
131
131
  return message;
132
132
  },
133
133
  };
134
+ const baseCoinSent = { sender: "", receiver: "" };
135
+ exports.CoinSent = {
136
+ encode(message, writer = minimal_1.default.Writer.create()) {
137
+ if (message.sender !== "") {
138
+ writer.uint32(10).string(message.sender);
139
+ }
140
+ if (message.receiver !== "") {
141
+ writer.uint32(18).string(message.receiver);
142
+ }
143
+ for (const v of message.amount) {
144
+ coin_1.Coin.encode(v, writer.uint32(26).fork()).ldelim();
145
+ }
146
+ return writer;
147
+ },
148
+ decode(input, length) {
149
+ const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
150
+ let end = length === undefined ? reader.len : reader.pos + length;
151
+ const message = Object.assign({}, baseCoinSent);
152
+ message.amount = [];
153
+ while (reader.pos < end) {
154
+ const tag = reader.uint32();
155
+ switch (tag >>> 3) {
156
+ case 1:
157
+ message.sender = reader.string();
158
+ break;
159
+ case 2:
160
+ message.receiver = reader.string();
161
+ break;
162
+ case 3:
163
+ message.amount.push(coin_1.Coin.decode(reader, reader.uint32()));
164
+ break;
165
+ default:
166
+ reader.skipType(tag & 7);
167
+ break;
168
+ }
169
+ }
170
+ return message;
171
+ },
172
+ fromJSON(object) {
173
+ var _a;
174
+ const message = Object.assign({}, baseCoinSent);
175
+ message.sender =
176
+ object.sender !== undefined && object.sender !== null
177
+ ? String(object.sender)
178
+ : "";
179
+ message.receiver =
180
+ object.receiver !== undefined && object.receiver !== null
181
+ ? String(object.receiver)
182
+ : "";
183
+ message.amount = ((_a = object.amount) !== null && _a !== void 0 ? _a : []).map((e) => coin_1.Coin.fromJSON(e));
184
+ return message;
185
+ },
186
+ toJSON(message) {
187
+ const obj = {};
188
+ message.sender !== undefined && (obj.sender = message.sender);
189
+ message.receiver !== undefined && (obj.receiver = message.receiver);
190
+ if (message.amount) {
191
+ obj.amount = message.amount.map((e) => (e ? coin_1.Coin.toJSON(e) : undefined));
192
+ }
193
+ else {
194
+ obj.amount = [];
195
+ }
196
+ return obj;
197
+ },
198
+ fromPartial(object) {
199
+ var _a, _b, _c;
200
+ const message = Object.assign({}, baseCoinSent);
201
+ message.sender = (_a = object.sender) !== null && _a !== void 0 ? _a : "";
202
+ message.receiver = (_b = object.receiver) !== null && _b !== void 0 ? _b : "";
203
+ message.amount = ((_c = object.amount) !== null && _c !== void 0 ? _c : []).map((e) => coin_1.Coin.fromPartial(e));
204
+ return message;
205
+ },
206
+ };
134
207
  if (minimal_1.default.util.Long !== long_1.default) {
135
208
  minimal_1.default.util.Long = long_1.default;
136
209
  minimal_1.default.configure();
@@ -1,11 +1,59 @@
1
+ import Long from "long";
2
+ import _m0 from "protobufjs/minimal";
3
+ import { PageRequest, PageResponse } from "../query/pagination";
1
4
  export declare const protobufPackage = "Switcheo.carbon.bank";
5
+ export interface InternalTransfer {
6
+ sender: string;
7
+ receiver: string;
8
+ denom: string;
9
+ amount: string;
10
+ transactionHash: string;
11
+ }
12
+ export interface QueryInternalTransfersRequest {
13
+ address: string;
14
+ denom: string;
15
+ pagination?: PageRequest;
16
+ }
17
+ export interface QueryInternalTransfersResponse {
18
+ internalTransfers: InternalTransfer[];
19
+ pagination?: PageResponse;
20
+ }
21
+ export declare const InternalTransfer: {
22
+ encode(message: InternalTransfer, writer?: _m0.Writer): _m0.Writer;
23
+ decode(input: _m0.Reader | Uint8Array, length?: number | undefined): InternalTransfer;
24
+ fromJSON(object: any): InternalTransfer;
25
+ toJSON(message: InternalTransfer): unknown;
26
+ fromPartial(object: DeepPartial<InternalTransfer>): InternalTransfer;
27
+ };
28
+ export declare const QueryInternalTransfersRequest: {
29
+ encode(message: QueryInternalTransfersRequest, writer?: _m0.Writer): _m0.Writer;
30
+ decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryInternalTransfersRequest;
31
+ fromJSON(object: any): QueryInternalTransfersRequest;
32
+ toJSON(message: QueryInternalTransfersRequest): unknown;
33
+ fromPartial(object: DeepPartial<QueryInternalTransfersRequest>): QueryInternalTransfersRequest;
34
+ };
35
+ export declare const QueryInternalTransfersResponse: {
36
+ encode(message: QueryInternalTransfersResponse, writer?: _m0.Writer): _m0.Writer;
37
+ decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryInternalTransfersResponse;
38
+ fromJSON(object: any): QueryInternalTransfersResponse;
39
+ toJSON(message: QueryInternalTransfersResponse): unknown;
40
+ fromPartial(object: DeepPartial<QueryInternalTransfersResponse>): QueryInternalTransfersResponse;
41
+ };
42
+ /** Query defines the gRPC querier service. */
2
43
  export interface Query {
44
+ /** this line is used by starport scaffolding # 2 */
45
+ InternalTransfers(request: QueryInternalTransfersRequest): Promise<QueryInternalTransfersResponse>;
3
46
  }
4
47
  export declare class QueryClientImpl implements Query {
5
48
  private readonly rpc;
6
49
  constructor(rpc: Rpc);
50
+ InternalTransfers(request: QueryInternalTransfersRequest): Promise<QueryInternalTransfersResponse>;
7
51
  }
8
52
  interface Rpc {
9
53
  request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
10
54
  }
55
+ declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
56
+ export declare type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
57
+ [K in keyof T]?: DeepPartial<T[K]>;
58
+ } : Partial<T>;
11
59
  export {};