carbon-js-sdk 0.11.73 → 0.11.74

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.
@@ -128,6 +128,7 @@ declare class CarbonSDK {
128
128
  connectWithMetamask(metamask: MetaMask, opts?: CarbonWalletGenericOpts, evmWalletOpts?: EvmWalletOpts): Promise<ConnectedCarbonSDK>;
129
129
  connectWithRainbowKit(rainbowKit: RainbowKitAccount, rainbowKitWalletOpts: RainbowKitWalletOpts, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
130
130
  connectViewOnly(bech32Address: string, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
131
+ connectWithQr(granteeMnemonic: string, granterAddress: string, expiry: Date, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
131
132
  getConfig(): NetworkConfig;
132
133
  getTokenClient(): TokenClient;
133
134
  getConnectedWallet(): CarbonWallet;
package/lib/CarbonSDK.js CHANGED
@@ -265,24 +265,31 @@ class CarbonSDK {
265
265
  return new CarbonSDK(opts);
266
266
  }
267
267
  async connectWithPrivateKey(privateKey, opts) {
268
- const wallet = wallet_1.CarbonWallet.withPrivateKey(privateKey, {
268
+ const wallet = new wallet_1.CarbonWallet({
269
269
  ...opts,
270
+ mode: "privateKey",
271
+ privateKey,
270
272
  network: this.network,
271
273
  config: this.configOverride,
272
274
  });
273
275
  return this.connect(wallet, opts);
274
276
  }
275
277
  async connectWithMnemonic(mnemonic, opts) {
276
- const wallet = wallet_1.CarbonWallet.withMnemonic(mnemonic, {
278
+ const wallet = new wallet_1.CarbonWallet({
277
279
  ...opts,
280
+ mode: "mnemonic",
281
+ mnemonic,
278
282
  network: this.network,
279
283
  config: this.configOverride,
280
284
  });
281
285
  return this.connect(wallet, opts);
282
286
  }
283
287
  async connectWithSigner(signer, publicKeyBase64, opts) {
284
- const wallet = wallet_1.CarbonWallet.withSigner(signer, publicKeyBase64, {
288
+ const wallet = new wallet_1.CarbonWallet({
285
289
  ...opts,
290
+ mode: "customSigner",
291
+ signer,
292
+ publicKeyBase64,
286
293
  network: this.network,
287
294
  config: this.configOverride,
288
295
  });
@@ -291,8 +298,12 @@ class CarbonSDK {
291
298
  async connectWithLedger(ledger, opts) {
292
299
  const publicKeyBuffer = await ledger.getPubKey();
293
300
  const publicKeyBase64 = publicKeyBuffer.toString("base64");
294
- const wallet = wallet_1.CarbonWallet.withLedger(ledger, publicKeyBase64, {
301
+ const signer = new wallet_1.CarbonLedgerSigner(ledger);
302
+ const wallet = new wallet_1.CarbonWallet({
295
303
  ...opts,
304
+ mode: "customSigner",
305
+ signer,
306
+ publicKeyBase64,
296
307
  network: this.network,
297
308
  config: this.configOverride,
298
309
  });
@@ -304,10 +315,18 @@ class CarbonSDK {
304
315
  await keplr.experimentalSuggestChain(chainInfo);
305
316
  const keplrKey = await keplr.getKey(chainId);
306
317
  await keplr.enable(chainId);
307
- const wallet = wallet_1.CarbonWallet.withKeplr(keplr, chainInfo, keplrKey, {
318
+ const signer = keplrKey.isNanoLedger
319
+ ? provider_1.KeplrAccount.createKeplrSignerAmino(keplr, chainInfo, keplrKey)
320
+ : provider_1.KeplrAccount.createKeplrSigner(keplr, chainInfo, keplrKey);
321
+ const publicKeyBase64 = Buffer.from(keplrKey.pubKey).toString("base64");
322
+ const wallet = new wallet_1.CarbonWallet({
308
323
  ...opts,
324
+ mode: "customSigner",
325
+ signer,
326
+ publicKeyBase64,
309
327
  network: this.network,
310
328
  config: this.configOverride,
329
+ providerAgent: constant_1.ProviderAgent.KeplrExtension,
311
330
  });
312
331
  return this.connect(wallet, opts);
313
332
  }
@@ -317,10 +336,16 @@ class CarbonSDK {
317
336
  await leap.experimentalSuggestChain(chainInfo);
318
337
  const leapKey = await leap.getKey(chainId);
319
338
  await leap.enable(chainId);
320
- const wallet = wallet_1.CarbonWallet.withLeap(leap, chainId, leapKey, {
339
+ const signer = leapKey.isNanoLedger ? provider_1.LeapAccount.createLeapSignerAmino(leap, chainId) : provider_1.LeapAccount.createLeapSigner(leap, chainId);
340
+ const publicKeyBase64 = Buffer.from(leapKey.pubKey).toString("base64");
341
+ const wallet = new wallet_1.CarbonWallet({
321
342
  ...opts,
343
+ mode: "customSigner",
344
+ signer,
345
+ publicKeyBase64,
322
346
  network: this.network,
323
347
  config: this.configOverride,
348
+ providerAgent: constant_1.ProviderAgent.LeapExtension,
324
349
  });
325
350
  return this.connect(wallet, opts);
326
351
  }
@@ -341,10 +366,15 @@ class CarbonSDK {
341
366
  message = result.message;
342
367
  signature = result.signature;
343
368
  }
344
- const wallet = wallet_1.CarbonWallet.withMetamask(metamask, evmChainId, pubKey, addressOptions, {
369
+ const signer = MetaMask_1.MetaMask.createMetamaskSigner(metamask, evmChainId, pubKey, addressOptions);
370
+ const wallet = new wallet_1.CarbonWallet({
345
371
  ...opts,
372
+ mode: "customSigner",
373
+ signer,
374
+ publicKeyBase64: pubKey,
346
375
  network: this.network,
347
376
  config: this.configOverride,
377
+ providerAgent: constant_1.ProviderAgent.MetamaskExtension,
348
378
  });
349
379
  if (noJwtProvided) {
350
380
  const authRequest = {
@@ -374,10 +404,16 @@ class CarbonSDK {
374
404
  message = result.message;
375
405
  signature = result.signature;
376
406
  }
377
- const wallet = wallet_1.CarbonWallet.withRainbowKit(rainbowKit, evmChainId, pubKey, addressOptions, rainbowKitWalletOpts.walletProvider, {
407
+ const signer = RainbowKitAccount_1.default.createRainbowKitSigner(rainbowKit, evmChainId, pubKey, addressOptions);
408
+ const wallet = new wallet_1.CarbonWallet({
378
409
  ...opts,
410
+ mode: "customSigner",
411
+ signer,
412
+ publicKeyBase64: pubKey,
379
413
  network: this.network,
380
414
  config: this.configOverride,
415
+ providerAgent: rainbowKitWalletOpts.walletProvider,
416
+ isRainbowKit: true,
381
417
  });
382
418
  if (noJwtProvided) {
383
419
  const authRequest = {
@@ -391,8 +427,23 @@ class CarbonSDK {
391
427
  return this.connect(wallet, opts);
392
428
  }
393
429
  async connectViewOnly(bech32Address, opts) {
394
- const wallet = wallet_1.CarbonWallet.withAddress(bech32Address, {
430
+ const wallet = new wallet_1.CarbonWallet({
395
431
  ...opts,
432
+ mode: "viewOnly",
433
+ bech32Address,
434
+ network: this.network,
435
+ config: this.configOverride,
436
+ });
437
+ return this.connect(wallet, opts);
438
+ }
439
+ async connectWithQr(granteeMnemonic, granterAddress, expiry, opts) {
440
+ const wallet = new wallet_1.CarbonWallet({
441
+ ...opts,
442
+ mode: "qr",
443
+ mnemonic: granteeMnemonic,
444
+ granter: granterAddress,
445
+ bech32Address: granterAddress,
446
+ expiry,
396
447
  network: this.network,
397
448
  config: this.configOverride,
398
449
  });
@@ -4,21 +4,15 @@ import { CarbonQueryClient } from "../clients";
4
4
  import GasFee from "../clients/GasFee";
5
5
  import { Network, NetworkConfig, SupportedEip6963Provider } from "../constant";
6
6
  import { ProviderAgent } from "../constant/walletProvider";
7
- import { ChainInfo, CosmosLedger, Keplr, MetaMask } from "../provider";
8
- import RainbowKitAccount from "../provider/rainbowKit/RainbowKitAccount";
9
7
  import { CarbonTx } from "../util";
10
- import { SWTHAddressOptions } from "../util/address";
11
8
  import { AccessTokenResponse, GrantRequest } from "../util/auth";
12
9
  import { SmartWalletBlockchain } from "../util/blockchain";
13
10
  import { BroadcastTxMode } from "../util/tx";
14
11
  import { StdSignature } from "@cosmjs/amino";
15
- import { EncodeObject, OfflineDirectSigner, OfflineSigner } from "@cosmjs/proto-signing";
12
+ import { EncodeObject, OfflineDirectSigner } from "@cosmjs/proto-signing";
16
13
  import { Account, DeliverTxResponse } from "@cosmjs/stargate";
17
14
  import { Tendermint37Client } from "@cosmjs/tendermint-rpc";
18
15
  import { BroadcastTxAsyncResponse, BroadcastTxSyncResponse, TxResponse } from "@cosmjs/tendermint-rpc/build/tendermint37/responses";
19
- import { Key as LeapKey } from "@cosmos-kit/core";
20
- import { Leap } from "@cosmos-kit/leap-extension";
21
- import { Key } from "@keplr-wallet/types";
22
16
  import { TxRaw as StargateTxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
23
17
  import { CarbonSigner, CarbonSignerTypes } from "./CarbonSigner";
24
18
  import { CarbonSigningClient } from "./CarbonSigningClient";
@@ -36,6 +30,7 @@ export interface CarbonWalletGenericOpts {
36
30
  enableJwtAuth?: boolean;
37
31
  authMessage?: string;
38
32
  jwt?: AccessTokenResponse;
33
+ bech32Address?: string;
39
34
  /**
40
35
  * Optional callback that will be called before signing is requested/executed.
41
36
  */
@@ -71,35 +66,30 @@ export interface EvmWalletOpts {
71
66
  export interface RainbowKitWalletOpts extends EvmWalletOpts {
72
67
  walletProvider: SupportedEip6963Provider;
73
68
  }
74
- export type CarbonWalletInitOpts = CarbonWalletGenericOpts & ({
69
+ type MnemonicOpts = {
70
+ mode: "mnemonic";
75
71
  mnemonic: string;
76
- privateKey?: string | Buffer;
77
- signer?: CarbonSigner;
78
- publicKeyBase64?: string;
79
- bech32Address?: string;
80
- customSigner?: OfflineSigner & OfflineDirectSigner;
81
- } | {
82
- mnemonic?: string;
72
+ };
73
+ type PrivateKeyOpts = {
74
+ mode: "privateKey";
83
75
  privateKey: string | Buffer;
84
- signer?: CarbonSigner;
85
- publicKeyBase64?: string;
86
- bech32Address?: string;
87
- customSigner?: OfflineSigner & OfflineDirectSigner;
88
- } | {
89
- mnemonic?: string;
90
- privateKey?: string | Buffer;
76
+ };
77
+ type CustomSignerOpts = {
78
+ mode: "customSigner";
91
79
  signer: CarbonSigner;
92
80
  publicKeyBase64: string;
93
- bech32Address?: string;
94
- customSigner?: OfflineSigner & OfflineDirectSigner;
95
- } | {
96
- mnemonic?: string;
97
- privateKey?: string | Buffer;
98
- signer?: CarbonSigner;
99
- publicKeyBase64?: string;
81
+ };
82
+ type ViewOnlyOpts = {
83
+ mode: "viewOnly";
100
84
  bech32Address: string;
101
- customSigner?: OfflineSigner & OfflineDirectSigner;
102
- });
85
+ };
86
+ type QROpts = {
87
+ mode: "qr";
88
+ mnemonic: string;
89
+ granter: string;
90
+ expiry: Date;
91
+ };
92
+ export type CarbonWalletInitOpts = CarbonWalletGenericOpts & (MnemonicOpts | PrivateKeyOpts | CustomSignerOpts | ViewOnlyOpts | QROpts);
103
93
  export interface AccountInfo extends Account {
104
94
  chainId: string;
105
95
  }
@@ -147,15 +137,6 @@ export declare class CarbonWallet {
147
137
  private txSignManager;
148
138
  private txDispatchManager;
149
139
  constructor(opts: CarbonWalletInitOpts);
150
- static withPrivateKey(privateKey: string | Buffer, opts?: Omit<CarbonWalletInitOpts, "privateKey">): CarbonWallet;
151
- static withMnemonic(mnemonic: string, opts?: Omit<CarbonWalletInitOpts, "mnemonic">): CarbonWallet;
152
- static withLedger(cosmosLedger: CosmosLedger, publicKeyBase64: string, opts?: Omit<CarbonWalletInitOpts, "signer">): CarbonWallet;
153
- static withSigner(signer: CarbonSigner, publicKeyBase64: string, opts?: Omit<CarbonWalletInitOpts, "signer">): CarbonWallet;
154
- static withKeplr(keplr: Keplr, chainInfo: ChainInfo, keplrKey: Key, opts?: Omit<CarbonWalletInitOpts, "signer">): CarbonWallet;
155
- static withLeap(leap: Leap, chainId: string, leapKey: LeapKey, opts?: Omit<CarbonWalletInitOpts, "signer">): CarbonWallet;
156
- static withMetamask(metamask: MetaMask, evmChainId: string, compressedPubKeyBase64: string, addressOptions: SWTHAddressOptions, opts?: Omit<CarbonWalletInitOpts, "signer">): CarbonWallet;
157
- static withRainbowKit(rainbowKit: RainbowKitAccount, evmChainId: string, compressedPubKeyBase64: string, addressOptions: SWTHAddressOptions, walletProvider: SupportedEip6963Provider, opts?: Omit<CarbonWalletInitOpts, "signer">): CarbonWallet;
158
- static withAddress(bech32Address: string, opts?: Partial<CarbonWalletInitOpts>): CarbonWallet;
159
140
  initialize(queryClient: CarbonQueryClient, gasFee: GasFee, fallbackConfig?: OverrideConfig | null, opts?: CarbonWalletGenericOpts): Promise<CarbonWallet>;
160
141
  reloadJwtToken(request?: GrantRequest, authMessage?: string): Promise<void>;
161
142
  queryViewOnlyEvmHexAddress(): Promise<void>;
@@ -237,3 +218,4 @@ export declare namespace CarbonWallet {
237
218
  }
238
219
  const TxRaw: typeof StargateTxRaw;
239
220
  }
221
+ export {};
@@ -12,8 +12,6 @@ const constant_1 = require("../constant");
12
12
  const grant_1 = require("../constant/grant");
13
13
  const walletProvider_1 = require("../constant/walletProvider");
14
14
  const grant_2 = require("../modules/grant");
15
- const provider_1 = require("../provider");
16
- const RainbowKitAccount_1 = __importDefault(require("../provider/rainbowKit/RainbowKitAccount"));
17
15
  const util_1 = require("../util");
18
16
  const address_1 = require("../util/address");
19
17
  const auth_2 = require("../util/auth");
@@ -82,115 +80,79 @@ class CarbonWallet {
82
80
  this.onAuthComplete = opts.onAuthComplete;
83
81
  this.txDispatchManager = new generic_1.QueueManager(this.dispatchTx.bind(this));
84
82
  this.txSignManager = new generic_1.QueueManager(this.signTx.bind(this));
85
- this.mnemonic = opts.mnemonic;
86
- if (this.mnemonic) {
87
- this.privateKey = util_1.AddressUtils.SWTHAddress.mnemonicToPrivateKey(this.mnemonic);
88
- }
89
- else if (opts.privateKey) {
90
- this.privateKey = util_1.AddressUtils.stringOrBufferToBuffer(opts.privateKey);
91
- }
83
+ // this.mnemonic = opts.mnemonic;
84
+ // if (this.mnemonic) {
85
+ // this.privateKey = AddressUtils.SWTHAddress.mnemonicToPrivateKey(this.mnemonic);
86
+ // } else if ("privateKey" in opts && opts.privateKey) {
87
+ // this.privateKey = AddressUtils.stringOrBufferToBuffer(opts.privateKey)!;
88
+ // }
92
89
  const addressOpts = {
93
90
  network,
94
91
  ...(this.configOverride.Bech32Prefix && {
95
92
  bech32Prefix: this.configOverride.Bech32Prefix,
96
93
  }),
97
94
  };
98
- if (opts.signer) {
99
- this.signer = opts.signer;
100
- this.publicKey = Buffer.from(opts.publicKeyBase64, "base64");
101
- this.bech32Address = util_1.AddressUtils.SWTHAddress.publicKeyToAddress(this.publicKey, addressOpts);
102
- }
103
- else if (this.privateKey) {
104
- this.publicKey = util_1.AddressUtils.SWTHAddress.privateToPublicKey(this.privateKey);
105
- this.bech32Address = util_1.AddressUtils.SWTHAddress.publicKeyToAddress(this.publicKey, addressOpts);
106
- let prefix = addressOpts.bech32Prefix;
107
- if (!addressOpts.bech32Prefix)
108
- prefix = address_1.SWTHAddress.getBech32Prefix(addressOpts?.network, addressOpts?.bech32Prefix);
109
- if (!prefix)
110
- throw new Error("cannot instantiate wallet signer, no prefix");
111
- this.signer = new CarbonSigner_1.CarbonPrivateKeySigner((0, bytes_1.toUint8Array)(this.privateKey), prefix);
112
- }
113
- else if (opts.bech32Address) {
114
- // read-only wallet, without private/public keys
115
- this.signer = new CarbonSigner_1.CarbonNonSigner();
116
- this.publicKey = Buffer.from([]);
117
- this.bech32Address = opts.bech32Address;
118
- }
119
- else {
120
- throw new Error("cannot instantiate wallet signer");
95
+ switch (opts.mode) {
96
+ case "mnemonic": {
97
+ this.mnemonic = opts.mnemonic;
98
+ this.privateKey = util_1.AddressUtils.SWTHAddress.mnemonicToPrivateKey(this.mnemonic);
99
+ this.publicKey = util_1.AddressUtils.SWTHAddress.privateToPublicKey(this.privateKey);
100
+ this.bech32Address = util_1.AddressUtils.SWTHAddress.publicKeyToAddress(this.publicKey, addressOpts);
101
+ let prefix = addressOpts.bech32Prefix;
102
+ if (!addressOpts.bech32Prefix)
103
+ prefix = address_1.SWTHAddress.getBech32Prefix(addressOpts?.network, addressOpts?.bech32Prefix);
104
+ if (!prefix)
105
+ throw new Error("cannot instantiate wallet signer, no prefix");
106
+ this.signer = new CarbonSigner_1.CarbonPrivateKeySigner((0, bytes_1.toUint8Array)(this.privateKey), prefix);
107
+ break;
108
+ }
109
+ case "privateKey": {
110
+ this.privateKey = util_1.AddressUtils.stringOrBufferToBuffer(opts.privateKey);
111
+ this.publicKey = util_1.AddressUtils.SWTHAddress.privateToPublicKey(this.privateKey);
112
+ this.bech32Address = util_1.AddressUtils.SWTHAddress.publicKeyToAddress(this.publicKey, addressOpts);
113
+ let prefix = addressOpts.bech32Prefix;
114
+ if (!addressOpts.bech32Prefix)
115
+ prefix = address_1.SWTHAddress.getBech32Prefix(addressOpts?.network, addressOpts?.bech32Prefix);
116
+ if (!prefix)
117
+ throw new Error("cannot instantiate wallet signer, no prefix");
118
+ this.signer = new CarbonSigner_1.CarbonPrivateKeySigner((0, bytes_1.toUint8Array)(this.privateKey), prefix);
119
+ break;
120
+ }
121
+ case "customSigner": {
122
+ this.signer = opts.signer;
123
+ this.publicKey = Buffer.from(opts.publicKeyBase64, "base64");
124
+ this.bech32Address = util_1.AddressUtils.SWTHAddress.publicKeyToAddress(this.publicKey, addressOpts);
125
+ break;
126
+ }
127
+ case "viewOnly": {
128
+ this.signer = new CarbonSigner_1.CarbonNonSigner();
129
+ this.publicKey = Buffer.from([]);
130
+ this.bech32Address = opts.bech32Address;
131
+ break;
132
+ }
133
+ case "qr": {
134
+ if (!opts.mnemonic || !opts.expiry || !opts.granter)
135
+ throw new Error("grantor, grantee and expiry must be provided to create grantee wallet");
136
+ this.publicKey = Buffer.from([]);
137
+ this.bech32Address = opts.granter;
138
+ let prefix = addressOpts.bech32Prefix;
139
+ if (!addressOpts.bech32Prefix)
140
+ prefix = address_1.SWTHAddress.getBech32Prefix(addressOpts?.network, addressOpts?.bech32Prefix);
141
+ if (!prefix)
142
+ throw new Error("cannot instantiate wallet signer, no prefix");
143
+ const pkSigner = new CarbonSigner_1.CarbonPrivateKeySigner((0, bytes_1.toUint8Array)(util_1.AddressUtils.SWTHAddress.mnemonicToPrivateKey(opts.mnemonic)), prefix);
144
+ this.signer = pkSigner;
145
+ this.setGrantee({
146
+ expiry: opts.expiry,
147
+ signer: pkSigner,
148
+ });
149
+ break;
150
+ }
121
151
  }
122
152
  const addressBytes = util_1.AddressUtils.SWTHAddress.getAddressBytes(this.bech32Address, this.network);
123
153
  this.hexAddress = `0x${Buffer.from(addressBytes).toString("hex")}`;
124
- this.evmHexAddress = opts.bech32Address ? '' : util_1.AddressUtils.ETHAddress.publicKeyToAddress(this.publicKey, addressOpts);
125
- this.evmBech32Address = opts.bech32Address ? '' : util_1.AddressUtils.ETHAddress.publicKeyToBech32Address(this.publicKey, addressOpts);
126
- }
127
- static withPrivateKey(privateKey, opts = {}) {
128
- return new CarbonWallet({
129
- ...opts,
130
- privateKey,
131
- });
132
- }
133
- static withMnemonic(mnemonic, opts = {}) {
134
- return new CarbonWallet({
135
- ...opts,
136
- mnemonic,
137
- });
138
- }
139
- static withLedger(cosmosLedger, publicKeyBase64, opts = {}) {
140
- const signer = new CarbonSigner_1.CarbonLedgerSigner(cosmosLedger);
141
- const wallet = CarbonWallet.withSigner(signer, publicKeyBase64, {
142
- providerAgent: walletProvider_1.ProviderAgent.Ledger,
143
- ...opts,
144
- });
145
- return wallet;
146
- }
147
- static withSigner(signer, publicKeyBase64, opts = {}) {
148
- return new CarbonWallet({
149
- ...opts,
150
- signer,
151
- publicKeyBase64,
152
- });
153
- }
154
- static withKeplr(keplr, chainInfo, keplrKey, opts = {}) {
155
- const signer = keplrKey.isNanoLedger ? provider_1.KeplrAccount.createKeplrSignerAmino(keplr, chainInfo, keplrKey) : provider_1.KeplrAccount.createKeplrSigner(keplr, chainInfo, keplrKey);
156
- const publicKeyBase64 = Buffer.from(keplrKey.pubKey).toString("base64");
157
- const wallet = CarbonWallet.withSigner(signer, publicKeyBase64, {
158
- providerAgent: walletProvider_1.ProviderAgent.KeplrExtension,
159
- ...opts,
160
- });
161
- return wallet;
162
- }
163
- static withLeap(leap, chainId, leapKey, opts = {}) {
164
- const signer = leapKey.isNanoLedger ? provider_1.LeapAccount.createLeapSignerAmino(leap, chainId) : provider_1.LeapAccount.createLeapSigner(leap, chainId);
165
- const publicKeyBase64 = Buffer.from(leapKey.pubKey).toString("base64");
166
- const wallet = CarbonWallet.withSigner(signer, publicKeyBase64, {
167
- providerAgent: walletProvider_1.ProviderAgent.LeapExtension,
168
- ...opts,
169
- });
170
- return wallet;
171
- }
172
- static withMetamask(metamask, evmChainId, compressedPubKeyBase64, addressOptions, opts = {}) {
173
- const signer = provider_1.MetaMask.createMetamaskSigner(metamask, evmChainId, compressedPubKeyBase64, addressOptions);
174
- const wallet = CarbonWallet.withSigner(signer, compressedPubKeyBase64, {
175
- providerAgent: walletProvider_1.ProviderAgent.MetamaskExtension,
176
- ...opts,
177
- });
178
- return wallet;
179
- }
180
- static withRainbowKit(rainbowKit, evmChainId, compressedPubKeyBase64, addressOptions, walletProvider, opts = {}) {
181
- const signer = RainbowKitAccount_1.default.createRainbowKitSigner(rainbowKit, evmChainId, compressedPubKeyBase64, addressOptions);
182
- const wallet = CarbonWallet.withSigner(signer, compressedPubKeyBase64, {
183
- ...opts,
184
- providerAgent: walletProvider,
185
- isRainbowKit: true,
186
- });
187
- return wallet;
188
- }
189
- static withAddress(bech32Address, opts = {}) {
190
- return new CarbonWallet({
191
- ...opts,
192
- bech32Address,
193
- });
154
+ this.evmHexAddress = this.bech32Address ? '' : util_1.AddressUtils.ETHAddress.publicKeyToAddress(this.publicKey, addressOpts);
155
+ this.evmBech32Address = this.bech32Address ? '' : util_1.AddressUtils.ETHAddress.publicKeyToBech32Address(this.publicKey, addressOpts);
194
156
  }
195
157
  async initialize(queryClient, gasFee, fallbackConfig = null, opts) {
196
158
  this.query = queryClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-js-sdk",
3
- "version": "0.11.73",
3
+ "version": "0.11.74",
4
4
  "description": "TypeScript SDK for Carbon blockchain",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",