@swapkit/toolboxes 1.0.0-beta.1 → 1.0.0-beta.11

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.
@@ -43,8 +43,8 @@ function secp256k1HdWalletFromMnemonic({
43
43
  derivationPath?: string;
44
44
  }) {
45
45
  return async function secp256k1HdWalletFromMnemonic(mnemonic: string, index = 0) {
46
- const { Secp256k1HdWallet } = await import("@cosmjs/amino");
47
- const { stringToPath } = await import("@cosmjs/crypto");
46
+ const { Secp256k1HdWallet } = (await import("@cosmjs/amino")).default;
47
+ const { stringToPath } = (await import("@cosmjs/crypto")).default;
48
48
 
49
49
  return Secp256k1HdWallet.fromMnemonic(mnemonic, {
50
50
  hdPaths: [stringToPath(`${derivationPath}/${index}`)],
@@ -114,8 +114,8 @@ function broadcastMultisigTx({
114
114
  threshold: number,
115
115
  bodyBytes: Uint8Array,
116
116
  ) {
117
- const { encodeSecp256k1Pubkey, pubkeyToAddress } = await import("@cosmjs/amino");
118
- const { makeMultisignedTxBytes } = await import("@cosmjs/stargate");
117
+ const { encodeSecp256k1Pubkey, pubkeyToAddress } = (await import("@cosmjs/amino")).default;
118
+ const { makeMultisignedTxBytes } = (await import("@cosmjs/stargate")).default;
119
119
 
120
120
  const { sequence, fee } = JSON.parse(tx);
121
121
  const multisigPubkey = await createMultisig(membersPubKeys, threshold);
@@ -142,7 +142,8 @@ function broadcastMultisigTx({
142
142
  }
143
143
 
144
144
  async function createMultisig(pubKeys: string[], threshold: number, noSortPubKeys = true) {
145
- const { createMultisigThresholdPubkey, encodeSecp256k1Pubkey } = await import("@cosmjs/amino");
145
+ const { createMultisigThresholdPubkey, encodeSecp256k1Pubkey } = (await import("@cosmjs/amino"))
146
+ .default;
146
147
  return createMultisigThresholdPubkey(
147
148
  pubKeys.map((pubKey) => encodeSecp256k1Pubkey(base64.decode(pubKey))),
148
149
  threshold,
@@ -161,7 +162,7 @@ async function signWithPrivateKey({
161
162
  privateKey: Uint8Array;
162
163
  message: string;
163
164
  }) {
164
- const { Secp256k1 } = await import("@cosmjs/crypto");
165
+ const { Secp256k1 } = (await import("@cosmjs/crypto")).default;
165
166
 
166
167
  const signature = await Secp256k1.createSignature(base64.decode(message), privateKey);
167
168
  return base64.encode(Buffer.concat([signature.r(32), signature.s(32)]));
@@ -301,7 +302,7 @@ export async function createThorchainToolbox({
301
302
  signWithPrivateKey,
302
303
  transfer,
303
304
  pubkeyToAddress: async (pubkey: Pubkey) => {
304
- const { pubkeyToAddress } = await import("@cosmjs/amino");
305
+ const { pubkeyToAddress } = (await import("@cosmjs/amino")).default;
305
306
  return pubkeyToAddress(pubkey, chainPrefix);
306
307
  },
307
308
  };
@@ -69,7 +69,7 @@ export const getDenomWithChain = ({ symbol, chain }: AssetValue) => {
69
69
  };
70
70
 
71
71
  export async function createStargateClient(url: string) {
72
- const { StargateClient } = await import("@cosmjs/stargate");
72
+ const { StargateClient } = (await import("@cosmjs/stargate")).default;
73
73
 
74
74
  return StargateClient.connect(url);
75
75
  }
@@ -79,7 +79,7 @@ export async function createSigningStargateClient(
79
79
  signer: any,
80
80
  optionsOrBaseGas: string | SigningStargateClientOptions = {},
81
81
  ) {
82
- const { SigningStargateClient, GasPrice } = await import("@cosmjs/stargate");
82
+ const { SigningStargateClient, GasPrice } = (await import("@cosmjs/stargate")).default;
83
83
  const gasPrice = typeof optionsOrBaseGas === "string" ? optionsOrBaseGas : "0.0003uatom";
84
84
  const options = typeof optionsOrBaseGas === "string" ? {} : optionsOrBaseGas;
85
85
 
@@ -93,7 +93,7 @@ export async function createOfflineStargateClient(
93
93
  wallet: OfflineSigner,
94
94
  registry?: SigningStargateClientOptions,
95
95
  ) {
96
- const { SigningStargateClient } = await import("@cosmjs/stargate");
96
+ const { SigningStargateClient } = (await import("@cosmjs/stargate")).default;
97
97
 
98
98
  return SigningStargateClient.offline(wallet, registry);
99
99
  }
@@ -538,6 +538,7 @@ function getEstimateGasLimit({ provider, signer }: ToolboxWrapParams) {
538
538
  assetValue,
539
539
  recipient,
540
540
  memo,
541
+ data,
541
542
  sender,
542
543
  funcName,
543
544
  funcParams,
@@ -547,6 +548,7 @@ function getEstimateGasLimit({ provider, signer }: ToolboxWrapParams) {
547
548
  funcName?: string;
548
549
  funcParams?: unknown[];
549
550
  txOverrides?: EVMTxParams;
551
+ data?: string;
550
552
  }) {
551
553
  // const value = assetValue.getBaseValue("bigint");
552
554
  const value = assetValue.bigIntValue;
@@ -573,7 +575,7 @@ function getEstimateGasLimit({ provider, signer }: ToolboxWrapParams) {
573
575
  from: sender,
574
576
  to: recipient,
575
577
  value,
576
- data: memo ? hexlify(toUtf8Bytes(memo)) : undefined,
578
+ data: data ? data : memo ? hexlify(toUtf8Bytes(memo)) : undefined,
577
579
  });
578
580
  };
579
581
  }
@@ -3,7 +3,6 @@ import {
3
3
  BaseDecimal,
4
4
  Chain,
5
5
  type ChainSigner,
6
- type GenericCreateTransactionParams,
7
6
  type GenericTransferParams,
8
7
  SKConfig,
9
8
  SwapKitError,
@@ -111,10 +110,7 @@ export const getRippleToolbox = async (params: RippleToolboxParams = {}) => {
111
110
  recipient,
112
111
  memo,
113
112
  sender,
114
- }: Omit<GenericCreateTransactionParams, "feeRate">) => {
115
- if (!signer) {
116
- throw new SwapKitError({ errorKey: "toolbox_ripple_signer_not_found" });
117
- }
113
+ }: { assetValue: AssetValue; recipient: string; sender?: string; memo?: string }) => {
118
114
  if (!rippleValidateAddress(recipient)) {
119
115
  throw new SwapKitError({ errorKey: "core_transaction_invalid_recipient_address" });
120
116
  }
@@ -160,7 +160,7 @@ async function createTransaction({
160
160
  // .inputs and .outputs will be undefined if no solution was found
161
161
  if (!(inputs && outputs)) throw new Error("Balance insufficient for transaction");
162
162
  const getNetwork = await getUtxoNetwork();
163
- const builder = new TransactionBuilder(getNetwork(chain));
163
+ const builder = new TransactionBuilder(getNetwork(chain)) as TransactionBuilderType;
164
164
 
165
165
  await Promise.all(
166
166
  inputs.map(async (utxo: UTXOType) => {
package/src/utxo/types.ts CHANGED
@@ -52,4 +52,6 @@ export type TransactionBuilderType = {
52
52
  signatureAlgorithm?: string,
53
53
  ): void;
54
54
  build(): TransactionType;
55
+ addOutput(addressOrScriptBuffer: string | Buffer, value: number): void;
56
+ addInput(txHash: string | Buffer, vout: number, sequence?: number, prevOutScript?: Buffer): void;
55
57
  };