carbon-js-sdk 0.11.1 → 0.11.2-beta.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.
@@ -15,6 +15,7 @@ import { CarbonSigner, CarbonWallet, CarbonWalletGenericOpts, MetaMaskWalletOpts
15
15
  export { CarbonTx } from "./util";
16
16
  export { CarbonSigner, CarbonSignerTypes, CarbonWallet, CarbonWalletGenericOpts, CarbonWalletInitOpts } from "./wallet";
17
17
  export * as Carbon from "./codec/carbon-models";
18
+ import RainbowKitAccount, { RainbowKitWalletOpts } from "./provider/rainbowKit/RainbowKitAccount";
18
19
  export interface CarbonSDKOpts {
19
20
  network: Network;
20
21
  tmClient: Tendermint37Client;
@@ -114,6 +115,7 @@ declare class CarbonSDK {
114
115
  static instanceWithKeplr(keplr: Keplr, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
115
116
  static instanceWithLeap(leap: LeapExtended, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
116
117
  static instanceWithMetamask(metamask: MetaMask, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts, metamaskWalletOpts?: MetaMaskWalletOpts): Promise<ConnectedCarbonSDK>;
118
+ static instanceWithRainbowKit(rainbowKit: RainbowKitAccount, sdkOpts: CarbonSDKInitOpts | undefined, rainbowKitWalletOpts: RainbowKitWalletOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
117
119
  static instanceViewOnly(bech32Address: string, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
118
120
  initialize(): Promise<CarbonSDK>;
119
121
  getGasFee(): Promise<GasFee>;
@@ -128,6 +130,7 @@ declare class CarbonSDK {
128
130
  connectWithKeplr(keplr: Keplr, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
129
131
  connectWithLeap(leap: LeapExtended, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
130
132
  connectWithMetamask(metamask: MetaMask, opts?: CarbonWalletGenericOpts, metamaskWalletOpts?: MetaMaskWalletOpts): Promise<ConnectedCarbonSDK>;
133
+ connectWithRainbowKit(rainbowKit: RainbowKitAccount, rainbowKitWalletOpts: RainbowKitWalletOpts, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
131
134
  connectViewOnly(bech32Address: string, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
132
135
  getConfig(): NetworkConfig;
133
136
  getTokenClient(): TokenClient;
package/lib/CarbonSDK.js CHANGED
@@ -232,6 +232,12 @@ class CarbonSDK {
232
232
  return sdk.connectWithMetamask(metamask, walletOpts, metamaskWalletOpts);
233
233
  });
234
234
  }
235
+ static instanceWithRainbowKit(rainbowKit, sdkOpts = DEFAULT_SDK_INIT_OPTS, rainbowKitWalletOpts, walletOpts) {
236
+ return __awaiter(this, void 0, void 0, function* () {
237
+ const sdk = yield CarbonSDK.instance(sdkOpts);
238
+ return sdk.connectWithRainbowKit(rainbowKit, rainbowKitWalletOpts, walletOpts);
239
+ });
240
+ }
235
241
  static instanceViewOnly(bech32Address, sdkOpts = DEFAULT_SDK_INIT_OPTS, walletOpts) {
236
242
  return __awaiter(this, void 0, void 0, function* () {
237
243
  const sdk = yield CarbonSDK.instance(sdkOpts);
@@ -394,6 +400,17 @@ class CarbonSDK {
394
400
  return this.connect(wallet);
395
401
  });
396
402
  }
403
+ connectWithRainbowKit(rainbowKit, rainbowKitWalletOpts, opts) {
404
+ return __awaiter(this, void 0, void 0, function* () {
405
+ const evmChainId = this.evmChainId;
406
+ const addressOptions = {
407
+ network: this.networkConfig.network,
408
+ bech32Prefix: this.networkConfig.Bech32Prefix,
409
+ };
410
+ const wallet = wallet_1.CarbonWallet.withRainbowKit(rainbowKit, evmChainId, rainbowKitWalletOpts.publicKeyBase64, addressOptions, rainbowKitWalletOpts.walletProvider, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
411
+ return this.connect(wallet);
412
+ });
413
+ }
397
414
  connectViewOnly(bech32Address, opts) {
398
415
  return __awaiter(this, void 0, void 0, function* () {
399
416
  const wallet = wallet_1.CarbonWallet.withAddress(bech32Address, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
@@ -24,3 +24,43 @@ export declare enum SupportedEip6963Provider {
24
24
  Fluvi = "Fluvi",
25
25
  SafeheronWallet = "Safeheron Wallet"
26
26
  }
27
+ interface EIP6963ProviderInfo {
28
+ walletId: string;
29
+ uuid: string;
30
+ name: string;
31
+ icon: string;
32
+ }
33
+ interface EIP1193Provider {
34
+ isStatus?: boolean;
35
+ host?: string;
36
+ path?: string;
37
+ isMetaMask: boolean;
38
+ chainId: string;
39
+ sendAsync?: (request: {
40
+ method: string;
41
+ params?: Array<unknown>;
42
+ }, callback: (error: Error | null, response: unknown) => void) => void;
43
+ send?: (request: {
44
+ method: string;
45
+ params?: Array<unknown>;
46
+ }, callback: (error: Error | null, response: unknown) => void) => void;
47
+ request: (request: {
48
+ method: string;
49
+ params?: Array<unknown>;
50
+ }) => Promise<unknown>;
51
+ on: (eventName: string, listener: (...args: unknown[]) => void) => any;
52
+ _state?: {
53
+ isConnected?: boolean;
54
+ };
55
+ }
56
+ export interface EIP6963ProviderDetail {
57
+ info: EIP6963ProviderInfo;
58
+ provider: EIP1193Provider;
59
+ }
60
+ export declare type EIP6963AnnounceProviderEvent = {
61
+ detail: {
62
+ info: EIP6963ProviderInfo;
63
+ provider: EIP1193Provider;
64
+ };
65
+ };
66
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { PageRequest } from "../codec/cosmos/base/query/v1beta1/pagination";
2
2
  import { StdFee } from "@cosmjs/amino";
3
3
  import BigNumber from "bignumber.js";
4
+ import { Blockchain, BlockchainV2, EVMChain as EVMChainV2 } from "../util/blockchain";
4
5
  export declare const DEFAULT_FEE_DENOM = "swth";
5
6
  export declare const DEFAULT_GAS_PRICE: BigNumber;
6
7
  export declare const DEFAULT_GAS: BigNumber;
@@ -12,3 +13,12 @@ export interface GasPriceStep {
12
13
  high: number;
13
14
  }
14
15
  export declare const CARBON_GAS_PRICE: GasPriceStep;
16
+ export interface RequestArguments {
17
+ method: string;
18
+ params?: unknown[] | object;
19
+ }
20
+ export declare type EVMChain = EVMChainV2;
21
+ export interface SyncResult {
22
+ blockchain?: Blockchain | BlockchainV2;
23
+ chainId?: number;
24
+ }
@@ -5,3 +5,5 @@ export * from "./network";
5
5
  export * from "./node";
6
6
  export * from "./token";
7
7
  export * from "./walletProvider";
8
+ export * from "./eip6963Provider";
9
+ export * from "./web3Config";
@@ -17,3 +17,5 @@ __exportStar(require("./network"), exports);
17
17
  __exportStar(require("./node"), exports);
18
18
  __exportStar(require("./token"), exports);
19
19
  __exportStar(require("./walletProvider"), exports);
20
+ __exportStar(require("./eip6963Provider"), exports);
21
+ __exportStar(require("./web3Config"), exports);
@@ -5,5 +5,6 @@ export declare enum ProviderAgent {
5
5
  LeapExtension = "leap-extension",
6
6
  MetamaskExtension = "metamask-extension",
7
7
  Metamask = "metamask",
8
- Web3Auth = "web3auth"
8
+ Web3Auth = "web3auth",
9
+ Rainbow = "rainbow"
9
10
  }
@@ -11,4 +11,5 @@ var ProviderAgent;
11
11
  // For legacy metamask
12
12
  ProviderAgent["Metamask"] = "metamask";
13
13
  ProviderAgent["Web3Auth"] = "web3auth";
14
+ ProviderAgent["Rainbow"] = "rainbow";
14
15
  })(ProviderAgent = exports.ProviderAgent || (exports.ProviderAgent = {}));
@@ -0,0 +1,31 @@
1
+ export interface ChangeNetworkParam {
2
+ chainId: string;
3
+ blockExplorerUrls?: string[];
4
+ chainName?: string;
5
+ iconUrls?: string[];
6
+ nativeCurrency?: {
7
+ name: string;
8
+ symbol: string;
9
+ decimals: number;
10
+ };
11
+ rpcUrls?: string[];
12
+ }
13
+ export declare const CarbonEvmNativeCurrency: {
14
+ decimals: number;
15
+ name: string;
16
+ symbol: string;
17
+ };
18
+ export declare const CARBON_EVM_LOCALHOST: ChangeNetworkParam;
19
+ export declare const CARBON_EVM_DEVNET: ChangeNetworkParam;
20
+ export declare const CARBON_EVM_TESTNET: ChangeNetworkParam;
21
+ export declare const CARBON_EVM_MAINNET: ChangeNetworkParam;
22
+ export declare const BSC_MAINNET: ChangeNetworkParam;
23
+ export declare const BSC_TESTNET: ChangeNetworkParam;
24
+ export declare const ETH_MAINNET: ChangeNetworkParam;
25
+ export declare const ETH_TESTNET: ChangeNetworkParam;
26
+ export declare const ARBITRUM_MAINNET: ChangeNetworkParam;
27
+ export declare const ARBITRUM_TESTNET: ChangeNetworkParam;
28
+ export declare const POLYGON_MAINNET: ChangeNetworkParam;
29
+ export declare const POLYGON_TESTNET: ChangeNetworkParam;
30
+ export declare const OKC_MAINNET: ChangeNetworkParam;
31
+ export declare const OKC_TESTNET: ChangeNetworkParam;
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OKC_TESTNET = exports.OKC_MAINNET = exports.POLYGON_TESTNET = exports.POLYGON_MAINNET = exports.ARBITRUM_TESTNET = exports.ARBITRUM_MAINNET = exports.ETH_TESTNET = exports.ETH_MAINNET = exports.BSC_TESTNET = exports.BSC_MAINNET = exports.CARBON_EVM_MAINNET = exports.CARBON_EVM_TESTNET = exports.CARBON_EVM_DEVNET = exports.CARBON_EVM_LOCALHOST = exports.CarbonEvmNativeCurrency = void 0;
4
+ const constant_1 = require("../constant");
5
+ const ethermint_1 = require("../util/ethermint");
6
+ exports.CarbonEvmNativeCurrency = {
7
+ decimals: 18,
8
+ name: "SWTH",
9
+ symbol: "SWTH",
10
+ };
11
+ exports.CARBON_EVM_LOCALHOST = {
12
+ chainId: `0x${Number(ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[constant_1.Network.LocalHost])).toString(16)}`,
13
+ blockExplorerUrls: ["https://evm-scan.carbon.network"],
14
+ chainName: "Carbon EVM Localhost",
15
+ rpcUrls: [`${constant_1.NetworkConfigs[constant_1.Network.LocalHost].evmJsonRpcUrl}`],
16
+ nativeCurrency: exports.CarbonEvmNativeCurrency,
17
+ };
18
+ exports.CARBON_EVM_DEVNET = {
19
+ chainId: `0x${Number(ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[constant_1.Network.DevNet])).toString(16)}`,
20
+ blockExplorerUrls: ["https://evm-scan.carbon.network"],
21
+ chainName: "Carbon EVM Devnet",
22
+ rpcUrls: [`${constant_1.NetworkConfigs[constant_1.Network.DevNet].evmJsonRpcUrl}`],
23
+ nativeCurrency: exports.CarbonEvmNativeCurrency,
24
+ };
25
+ exports.CARBON_EVM_TESTNET = {
26
+ chainId: `0x${Number(ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[constant_1.Network.TestNet])).toString(16)}`,
27
+ blockExplorerUrls: ["https://evm-scan.carbon.network"],
28
+ chainName: "Carbon EVM Testnet",
29
+ rpcUrls: [`${constant_1.NetworkConfigs[constant_1.Network.TestNet].evmJsonRpcUrl}`],
30
+ nativeCurrency: exports.CarbonEvmNativeCurrency,
31
+ };
32
+ exports.CARBON_EVM_MAINNET = {
33
+ chainId: `0x${Number(ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[constant_1.Network.MainNet])).toString(16)}`,
34
+ blockExplorerUrls: ["https://evm-scan.carbon.network"],
35
+ chainName: "Carbon EVM",
36
+ rpcUrls: [`${constant_1.NetworkConfigs[constant_1.Network.MainNet].evmJsonRpcUrl}`],
37
+ nativeCurrency: exports.CarbonEvmNativeCurrency,
38
+ };
39
+ exports.BSC_MAINNET = {
40
+ chainId: "0x38",
41
+ blockExplorerUrls: ["https://bscscan.com"],
42
+ chainName: "BSC Mainnet",
43
+ rpcUrls: [
44
+ "https://bsc-dataseed2.binance.org/",
45
+ "https://bsc-dataseed3.binance.org/",
46
+ "https://bsc-dataseed4.binance.org/",
47
+ "https://bsc-dataseed1.defibit.io/",
48
+ "https://bsc-dataseed2.defibit.io/",
49
+ "https://bsc-dataseed3.defibit.io/",
50
+ "https://bsc-dataseed4.defibit.io/",
51
+ "https://bsc-dataseed1.ninicoin.io/",
52
+ "https://bsc-dataseed2.ninicoin.io/",
53
+ "https://bsc-dataseed3.ninicoin.io/",
54
+ "https://bsc-dataseed4.ninicoin.io/",
55
+ "https://bsc-dataseed1.binance.org/",
56
+ ],
57
+ nativeCurrency: {
58
+ decimals: 18,
59
+ name: "Binance Coin",
60
+ symbol: "BNB",
61
+ },
62
+ };
63
+ exports.BSC_TESTNET = {
64
+ chainId: "0x61",
65
+ blockExplorerUrls: ["https://testnet.bscscan.com"],
66
+ chainName: "BSC Testnet",
67
+ rpcUrls: [
68
+ "https://data-seed-prebsc-2-s1.binance.org:8545/",
69
+ "http://data-seed-prebsc-1-s2.binance.org:8545/",
70
+ "http://data-seed-prebsc-2-s2.binance.org:8545/",
71
+ "https://data-seed-prebsc-1-s3.binance.org:8545/",
72
+ "https://data-seed-prebsc-2-s3.binance.org:8545/",
73
+ "https://data-seed-prebsc-1-s1.binance.org:8545/",
74
+ ],
75
+ nativeCurrency: {
76
+ decimals: 18,
77
+ name: "Binance Coin",
78
+ symbol: "BNB",
79
+ },
80
+ };
81
+ exports.ETH_MAINNET = {
82
+ chainId: "0x1",
83
+ rpcUrls: ["https://mainnet.infura.io/v3/"],
84
+ };
85
+ exports.ETH_TESTNET = {
86
+ chainId: "0x5",
87
+ rpcUrls: ["https://goerli.infura.io/v3/"],
88
+ };
89
+ exports.ARBITRUM_MAINNET = {
90
+ chainId: "0xA4B1",
91
+ blockExplorerUrls: ["https://explorer.arbitrum.io"],
92
+ chainName: "Arbitrum One",
93
+ rpcUrls: ["https://arb1.arbitrum.io/rpc"],
94
+ nativeCurrency: {
95
+ decimals: 18,
96
+ name: "Ethereum",
97
+ symbol: "ETH",
98
+ },
99
+ };
100
+ exports.ARBITRUM_TESTNET = {
101
+ chainId: "0x66EEB",
102
+ blockExplorerUrls: [""],
103
+ chainName: "Arbitrum Testnet",
104
+ rpcUrls: ["https://rinkeby.arbitrum.io/rpc"],
105
+ nativeCurrency: {
106
+ decimals: 18,
107
+ name: "Ethereum",
108
+ symbol: "ETH",
109
+ },
110
+ };
111
+ exports.POLYGON_MAINNET = {
112
+ chainId: "0x89",
113
+ blockExplorerUrls: ["https://polygonscan.com/"],
114
+ chainName: "Polygon Mainnet",
115
+ rpcUrls: ["https://polygon-rpc.com"],
116
+ nativeCurrency: {
117
+ decimals: 18,
118
+ name: "Matic",
119
+ symbol: "MATIC",
120
+ },
121
+ };
122
+ exports.POLYGON_TESTNET = {
123
+ chainId: "0x13881",
124
+ blockExplorerUrls: ["https://mumbai.polygonscan.com"],
125
+ chainName: "Polygon Mumbai",
126
+ rpcUrls: ["https://polygon-mumbai.infura.io/v3/4458cf4d1689497b9a38b1d6bbf05e78"],
127
+ nativeCurrency: {
128
+ decimals: 18,
129
+ name: "Matic",
130
+ symbol: "MATIC",
131
+ },
132
+ };
133
+ exports.OKC_MAINNET = {
134
+ chainId: "0x42",
135
+ blockExplorerUrls: ["https://www.oklink.com/okc"],
136
+ chainName: "OKC Mainnet",
137
+ rpcUrls: ["https://exchainrpc.okex.org"],
138
+ nativeCurrency: {
139
+ decimals: 18,
140
+ name: "OKT",
141
+ symbol: "OKT",
142
+ },
143
+ };
144
+ exports.OKC_TESTNET = {
145
+ chainId: "0x41",
146
+ blockExplorerUrls: ["https://www.oklink.com/okc-test"],
147
+ chainName: "OKC Testnet",
148
+ rpcUrls: ["https://exchaintestrpc.okex.org"],
149
+ nativeCurrency: {
150
+ decimals: 18,
151
+ name: "OKT",
152
+ symbol: "OKT",
153
+ },
154
+ };
package/lib/index.d.ts CHANGED
@@ -4,9 +4,9 @@ export * as Models from "./codec";
4
4
  export * from "./util";
5
5
  export { Blockchain } from "./util/blockchain";
6
6
  export * from "./websocket";
7
- export { AminoTypesMap, SDKProvider, KeplrAccount, KeplrWindow, CosmosLedger, Keplr, ChainInfo, EVMChain, MetaMaskChangeNetworkParam, CallContractArgs, MetaMaskSyncResult, MetaMask, NeoLedgerAccount, Zilpay, ZilPayChangeNetworkParam, O3Types, O3Wallet, LeapAccount, Leap, Key, getSigningCosmosClientOptions, AssetList, Chain, LeapExtended, } from "./provider";
7
+ export { AminoTypesMap, SDKProvider, KeplrAccount, KeplrWindow, CosmosLedger, Keplr, ChainInfo, CallContractArgs, MetaMask, NeoLedgerAccount, Zilpay, ZilPayChangeNetworkParam, O3Types, O3Wallet, LeapAccount, Leap, Key, getSigningCosmosClientOptions, AssetList, Chain, LeapExtended, RainbowKitAccount, Eip6963Provider, } from "./provider";
8
8
  export { default as CarbonSDK } from "./CarbonSDK";
9
- export { ProviderAgent } from "./constant";
9
+ export { ProviderAgent, SupportedEip6963Provider, ChangeNetworkParam as MetaMaskChangeNetworkParam, EVMChain, SyncResult as MetaMaskSyncResult } from "./constant";
10
10
  export * as Insights from "./insights";
11
11
  export * as Hydrogen from "./hydrogen";
12
12
  export { CarbonSigner, DirectCarbonSigner, AminoCarbonSigner, CarbonLedgerSigner, CarbonPrivateKeySigner, CarbonNonSigner } from "./wallet";
package/lib/index.js CHANGED
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.CarbonNonSigner = exports.CarbonPrivateKeySigner = exports.CarbonLedgerSigner = exports.Hydrogen = exports.Insights = exports.ProviderAgent = exports.CarbonSDK = exports.getSigningCosmosClientOptions = exports.LeapAccount = exports.O3Wallet = exports.O3Types = exports.Zilpay = exports.NeoLedgerAccount = exports.MetaMask = exports.CosmosLedger = exports.KeplrAccount = exports.AminoTypesMap = exports.Blockchain = exports.Models = void 0;
28
+ exports.CarbonNonSigner = exports.CarbonPrivateKeySigner = exports.CarbonLedgerSigner = exports.Hydrogen = exports.Insights = exports.SupportedEip6963Provider = exports.ProviderAgent = exports.CarbonSDK = exports.Eip6963Provider = exports.RainbowKitAccount = exports.getSigningCosmosClientOptions = exports.LeapAccount = exports.O3Wallet = exports.O3Types = exports.Zilpay = exports.NeoLedgerAccount = exports.MetaMask = exports.CosmosLedger = exports.KeplrAccount = exports.AminoTypesMap = exports.Blockchain = exports.Models = void 0;
29
29
  __exportStar(require("./CarbonSDK"), exports);
30
30
  __exportStar(require("./modules"), exports);
31
31
  exports.Models = __importStar(require("./codec"));
@@ -44,10 +44,13 @@ Object.defineProperty(exports, "O3Types", { enumerable: true, get: function () {
44
44
  Object.defineProperty(exports, "O3Wallet", { enumerable: true, get: function () { return provider_1.O3Wallet; } });
45
45
  Object.defineProperty(exports, "LeapAccount", { enumerable: true, get: function () { return provider_1.LeapAccount; } });
46
46
  Object.defineProperty(exports, "getSigningCosmosClientOptions", { enumerable: true, get: function () { return provider_1.getSigningCosmosClientOptions; } });
47
+ Object.defineProperty(exports, "RainbowKitAccount", { enumerable: true, get: function () { return provider_1.RainbowKitAccount; } });
48
+ Object.defineProperty(exports, "Eip6963Provider", { enumerable: true, get: function () { return provider_1.Eip6963Provider; } });
47
49
  var CarbonSDK_1 = require("./CarbonSDK");
48
50
  Object.defineProperty(exports, "CarbonSDK", { enumerable: true, get: function () { return __importDefault(CarbonSDK_1).default; } });
49
51
  var constant_1 = require("./constant");
50
52
  Object.defineProperty(exports, "ProviderAgent", { enumerable: true, get: function () { return constant_1.ProviderAgent; } });
53
+ Object.defineProperty(exports, "SupportedEip6963Provider", { enumerable: true, get: function () { return constant_1.SupportedEip6963Provider; } });
51
54
  exports.Insights = __importStar(require("./insights"));
52
55
  exports.Hydrogen = __importStar(require("./hydrogen"));
53
56
  var wallet_1 = require("./wallet");
@@ -1,4 +1,4 @@
1
- import { SupportedEip6963Provider } from "../../constant";
1
+ import { EIP6963ProviderDetail, SupportedEip6963Provider } from "../../constant";
2
2
  declare class Eip6963Provider {
3
3
  private providers;
4
4
  constructor();
@@ -3,8 +3,11 @@ export { AminoTypesMap } from "./amino";
3
3
  export { ChainInfo, default as KeplrAccount, Keplr, KeplrWindow } from "./keplr";
4
4
  export { default as LeapAccount, Leap, Key, LeapExtended } from "./leap";
5
5
  export { default as CosmosLedger } from "./ledger";
6
- export { CallContractArgs, EVMChain, MetaMask, MetaMaskChangeNetworkParam, MetaMaskSyncResult } from "./metamask";
6
+ export { CallContractArgs, MetaMask } from "./metamask";
7
+ export { EVMChain, SyncResult as MetaMaskSyncResult } from "../constant";
7
8
  export { O3Types, O3Wallet } from "./o3";
8
9
  export { default as SDKProvider } from "./sdk";
9
10
  export { Zilpay, ZilPayChangeNetworkParam } from "./zilpay";
11
+ export { RainbowKitAccount } from './rainbowKit';
12
+ export { Eip6963Provider } from './eip6963Provider';
10
13
  export { getSigningCosmosClientOptions, AssetList, Chain } from "./chainProvider";
@@ -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.getSigningCosmosClientOptions = exports.Zilpay = exports.O3Wallet = exports.O3Types = exports.MetaMask = exports.CosmosLedger = exports.LeapAccount = exports.KeplrAccount = exports.AminoTypesMap = exports.NeoLedgerAccount = void 0;
6
+ exports.getSigningCosmosClientOptions = exports.Eip6963Provider = exports.RainbowKitAccount = exports.Zilpay = exports.O3Wallet = exports.O3Types = exports.MetaMask = exports.CosmosLedger = exports.LeapAccount = exports.KeplrAccount = exports.AminoTypesMap = exports.NeoLedgerAccount = void 0;
7
7
  var account_1 = require("./account");
8
8
  Object.defineProperty(exports, "NeoLedgerAccount", { enumerable: true, get: function () { return account_1.NeoLedgerAccount; } });
9
9
  var amino_1 = require("./amino");
@@ -21,5 +21,9 @@ Object.defineProperty(exports, "O3Types", { enumerable: true, get: function () {
21
21
  Object.defineProperty(exports, "O3Wallet", { enumerable: true, get: function () { return o3_1.O3Wallet; } });
22
22
  var zilpay_1 = require("./zilpay");
23
23
  Object.defineProperty(exports, "Zilpay", { enumerable: true, get: function () { return zilpay_1.Zilpay; } });
24
+ var rainbowKit_1 = require("./rainbowKit");
25
+ Object.defineProperty(exports, "RainbowKitAccount", { enumerable: true, get: function () { return rainbowKit_1.RainbowKitAccount; } });
26
+ var eip6963Provider_1 = require("./eip6963Provider");
27
+ Object.defineProperty(exports, "Eip6963Provider", { enumerable: true, get: function () { return eip6963Provider_1.Eip6963Provider; } });
24
28
  var chainProvider_1 = require("./chainProvider");
25
29
  Object.defineProperty(exports, "getSigningCosmosClientOptions", { enumerable: true, get: function () { return chainProvider_1.getSigningCosmosClientOptions; } });
@@ -1,44 +1,27 @@
1
- import { Network } from "../../constant";
2
- import { Blockchain, BlockchainV2, EVMChain as EVMChainV2 } from "../../util/blockchain";
1
+ import { EVMChain, Network, RequestArguments, SyncResult } from "../../constant";
2
+ import { BlockchainV2, EVMChain as EVMChainV2 } from "../../util/blockchain";
3
3
  import { ethers } from "ethers";
4
4
  import { CarbonSigner } from "../../wallet";
5
5
  import { CarbonSDK } from "../../index";
6
6
  import { StdFee } from "@cosmjs/stargate";
7
7
  import { AminoMsg } from "@cosmjs/amino";
8
8
  import { SWTHAddressOptions } from "../../util/address";
9
- export declare type EVMChain = EVMChainV2;
10
- interface RequestArguments {
11
- method: string;
12
- params?: unknown[] | object;
13
- }
9
+ import { Eip6963Provider } from "../eip6963Provider";
10
+ import { ChangeNetworkParam as MetaMaskChangeNetworkParam } from "../../constant";
14
11
  interface MetaMaskAPI {
15
12
  isMetaMask: boolean;
16
13
  chainId: string | null;
17
- isConnected: () => boolean;
14
+ _state: {
15
+ isConnected: boolean;
16
+ };
18
17
  request: (args: RequestArguments) => Promise<unknown>;
19
18
  on: (eventName: string, listener: (...args: unknown[]) => void) => any;
20
19
  }
21
- export interface MetaMaskChangeNetworkParam {
22
- chainId: string;
23
- blockExplorerUrls?: string[];
24
- chainName?: string;
25
- iconUrls?: string[];
26
- nativeCurrency?: {
27
- name: string;
28
- symbol: string;
29
- decimals: number;
30
- };
31
- rpcUrls?: string[];
32
- }
33
20
  export interface CallContractArgs {
34
21
  from?: string;
35
22
  value?: string;
36
23
  data?: string;
37
24
  }
38
- export interface MetaMaskSyncResult {
39
- blockchain?: Blockchain | BlockchainV2;
40
- chainId?: number;
41
- }
42
25
  export interface StoredMnemonicInfo {
43
26
  mnemonic: string;
44
27
  chain: EVMChainV2;
@@ -49,7 +32,7 @@ export interface StoredMnemonicInfo {
49
32
  /**
50
33
  * TODO: Add docs
51
34
  */
52
- export declare class MetaMask {
35
+ export declare class MetaMask extends Eip6963Provider {
53
36
  readonly network: Network;
54
37
  readonly legacyEip712SignMode: boolean;
55
38
  private blockchain;
@@ -62,9 +45,10 @@ export declare class MetaMask {
62
45
  private checkProvider;
63
46
  getBlockchain(): BlockchainV2;
64
47
  syncConnectedAccount(): Promise<string>;
65
- syncBlockchain(): Promise<MetaMaskSyncResult>;
48
+ syncBlockchain(): Promise<SyncResult>;
66
49
  getSigner(): Promise<ethers.Signer>;
67
50
  getAPI(): Promise<MetaMaskAPI | null>;
51
+ getMetaMaskProvider(): MetaMaskAPI | undefined;
68
52
  getConnectedAPI(): Promise<MetaMaskAPI>;
69
53
  connect(): Promise<MetaMaskAPI>;
70
54
  defaultAccount(): Promise<string>;
@@ -55,6 +55,8 @@ const detect_provider_1 = __importDefault(require("@metamask/detect-provider"));
55
55
  const error_1 = require("./error");
56
56
  const network_1 = require("../../util/network");
57
57
  const provider_1 = require("../../util/provider");
58
+ const eip6963Provider_1 = require("../eip6963Provider");
59
+ const constant_2 = require("../../constant");
58
60
  const CONTRACT_HASH = {
59
61
  Ethereum: {
60
62
  // use same rinkeby contract for all non-mainnet uses
@@ -114,160 +116,12 @@ const getEncryptMessage = (input) => {
114
116
  .trim()
115
117
  .replace(/^\s+/gm, "");
116
118
  };
117
- const CarbonEvmNativeCurrency = {
118
- decimals: 18,
119
- name: "SWTH",
120
- symbol: "SWTH",
121
- };
122
- const CARBON_EVM_LOCALHOST = {
123
- chainId: `0x${Number(ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[constant_1.Network.LocalHost])).toString(16)}`,
124
- blockExplorerUrls: ["https://evm-scan.carbon.network"],
125
- chainName: "Carbon EVM Localhost",
126
- rpcUrls: [`${constant_1.NetworkConfigs[constant_1.Network.LocalHost].evmJsonRpcUrl}`],
127
- nativeCurrency: CarbonEvmNativeCurrency,
128
- };
129
- const CARBON_EVM_DEVNET = {
130
- chainId: `0x${Number(ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[constant_1.Network.DevNet])).toString(16)}`,
131
- blockExplorerUrls: ["https://evm-scan.carbon.network"],
132
- chainName: "Carbon EVM Devnet",
133
- rpcUrls: [`${constant_1.NetworkConfigs[constant_1.Network.DevNet].evmJsonRpcUrl}`],
134
- nativeCurrency: CarbonEvmNativeCurrency,
135
- };
136
- const CARBON_EVM_TESTNET = {
137
- chainId: `0x${Number(ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[constant_1.Network.TestNet])).toString(16)}`,
138
- blockExplorerUrls: ["https://evm-scan.carbon.network"],
139
- chainName: "Carbon EVM Testnet",
140
- rpcUrls: [`${constant_1.NetworkConfigs[constant_1.Network.TestNet].evmJsonRpcUrl}`],
141
- nativeCurrency: CarbonEvmNativeCurrency,
142
- };
143
- const CARBON_EVM_MAINNET = {
144
- chainId: `0x${Number(ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[constant_1.Network.MainNet])).toString(16)}`,
145
- blockExplorerUrls: ["https://evm-scan.carbon.network"],
146
- chainName: "Carbon EVM",
147
- rpcUrls: [`${constant_1.NetworkConfigs[constant_1.Network.MainNet].evmJsonRpcUrl}`],
148
- nativeCurrency: CarbonEvmNativeCurrency,
149
- };
150
- const BSC_MAINNET = {
151
- chainId: "0x38",
152
- blockExplorerUrls: ["https://bscscan.com"],
153
- chainName: "BSC Mainnet",
154
- rpcUrls: [
155
- "https://bsc-dataseed2.binance.org/",
156
- "https://bsc-dataseed3.binance.org/",
157
- "https://bsc-dataseed4.binance.org/",
158
- "https://bsc-dataseed1.defibit.io/",
159
- "https://bsc-dataseed2.defibit.io/",
160
- "https://bsc-dataseed3.defibit.io/",
161
- "https://bsc-dataseed4.defibit.io/",
162
- "https://bsc-dataseed1.ninicoin.io/",
163
- "https://bsc-dataseed2.ninicoin.io/",
164
- "https://bsc-dataseed3.ninicoin.io/",
165
- "https://bsc-dataseed4.ninicoin.io/",
166
- "https://bsc-dataseed1.binance.org/",
167
- ],
168
- nativeCurrency: {
169
- decimals: 18,
170
- name: "Binance Coin",
171
- symbol: "BNB",
172
- },
173
- };
174
- const BSC_TESTNET = {
175
- chainId: "0x61",
176
- blockExplorerUrls: ["https://testnet.bscscan.com"],
177
- chainName: "BSC Testnet",
178
- rpcUrls: [
179
- "https://data-seed-prebsc-2-s1.binance.org:8545/",
180
- "http://data-seed-prebsc-1-s2.binance.org:8545/",
181
- "http://data-seed-prebsc-2-s2.binance.org:8545/",
182
- "https://data-seed-prebsc-1-s3.binance.org:8545/",
183
- "https://data-seed-prebsc-2-s3.binance.org:8545/",
184
- "https://data-seed-prebsc-1-s1.binance.org:8545/",
185
- ],
186
- nativeCurrency: {
187
- decimals: 18,
188
- name: "Binance Coin",
189
- symbol: "BNB",
190
- },
191
- };
192
- const ETH_MAINNET = {
193
- chainId: "0x1",
194
- rpcUrls: ["https://mainnet.infura.io/v3/"],
195
- };
196
- const ETH_TESTNET = {
197
- chainId: "0x5",
198
- rpcUrls: ["https://goerli.infura.io/v3/"],
199
- };
200
- const ARBITRUM_MAINNET = {
201
- chainId: "0xA4B1",
202
- blockExplorerUrls: ["https://explorer.arbitrum.io"],
203
- chainName: "Arbitrum One",
204
- rpcUrls: ["https://arb1.arbitrum.io/rpc"],
205
- nativeCurrency: {
206
- decimals: 18,
207
- name: "Ethereum",
208
- symbol: "ETH",
209
- },
210
- };
211
- const ARBITRUM_TESTNET = {
212
- chainId: "0x66EEB",
213
- blockExplorerUrls: [""],
214
- chainName: "Arbitrum Testnet",
215
- rpcUrls: ["https://rinkeby.arbitrum.io/rpc"],
216
- nativeCurrency: {
217
- decimals: 18,
218
- name: "Ethereum",
219
- symbol: "ETH",
220
- },
221
- };
222
- const POLYGON_MAINNET = {
223
- chainId: "0x89",
224
- blockExplorerUrls: ["https://polygonscan.com/"],
225
- chainName: "Polygon Mainnet",
226
- rpcUrls: ["https://polygon-rpc.com"],
227
- nativeCurrency: {
228
- decimals: 18,
229
- name: "Matic",
230
- symbol: "MATIC",
231
- },
232
- };
233
- const POLYGON_TESTNET = {
234
- chainId: "0x13881",
235
- blockExplorerUrls: ["https://mumbai.polygonscan.com"],
236
- chainName: "Polygon Mumbai",
237
- rpcUrls: ["https://polygon-mumbai.infura.io/v3/4458cf4d1689497b9a38b1d6bbf05e78"],
238
- nativeCurrency: {
239
- decimals: 18,
240
- name: "Matic",
241
- symbol: "MATIC",
242
- },
243
- };
244
- const OKC_MAINNET = {
245
- chainId: "0x42",
246
- blockExplorerUrls: ["https://www.oklink.com/okc"],
247
- chainName: "OKC Mainnet",
248
- rpcUrls: ["https://exchainrpc.okex.org"],
249
- nativeCurrency: {
250
- decimals: 18,
251
- name: "OKT",
252
- symbol: "OKT",
253
- },
254
- };
255
- const OKC_TESTNET = {
256
- chainId: "0x41",
257
- blockExplorerUrls: ["https://www.oklink.com/okc-test"],
258
- chainName: "OKC Testnet",
259
- rpcUrls: ["https://exchaintestrpc.okex.org"],
260
- nativeCurrency: {
261
- decimals: 18,
262
- name: "OKT",
263
- symbol: "OKT",
264
- },
265
- };
266
119
  /**
267
120
  * TODO: Add docs
268
121
  */
269
- class MetaMask {
122
+ class MetaMask extends eip6963Provider_1.Eip6963Provider {
270
123
  constructor(network, legacyEip712SignMode = false) {
124
+ super();
271
125
  this.network = network;
272
126
  this.legacyEip712SignMode = legacyEip712SignMode;
273
127
  this.blockchain = 'Ethereum';
@@ -378,42 +232,42 @@ class MetaMask {
378
232
  if (network === constant_1.Network.MainNet) {
379
233
  switch (blockchain) {
380
234
  case 'Binance Smart Chain':
381
- return BSC_MAINNET;
235
+ return constant_2.BSC_MAINNET;
382
236
  case 'Arbitrum':
383
- return ARBITRUM_MAINNET;
237
+ return constant_2.ARBITRUM_MAINNET;
384
238
  case 'Polygon':
385
- return POLYGON_MAINNET;
239
+ return constant_2.POLYGON_MAINNET;
386
240
  case 'OKC':
387
- return OKC_MAINNET;
241
+ return constant_2.OKC_MAINNET;
388
242
  default:
389
243
  // metamask should come with Ethereum configs
390
- return ETH_MAINNET;
244
+ return constant_2.ETH_MAINNET;
391
245
  }
392
246
  }
393
247
  switch (blockchain) {
394
248
  case 'Binance Smart Chain':
395
- return BSC_TESTNET;
249
+ return constant_2.BSC_TESTNET;
396
250
  case 'Arbitrum':
397
- return ARBITRUM_TESTNET;
251
+ return constant_2.ARBITRUM_TESTNET;
398
252
  case 'Polygon':
399
- return POLYGON_TESTNET;
253
+ return constant_2.POLYGON_TESTNET;
400
254
  case 'OKC':
401
- return OKC_TESTNET;
255
+ return constant_2.OKC_TESTNET;
402
256
  default:
403
257
  // metamask should come with Ethereum configs
404
- return ETH_TESTNET;
258
+ return constant_2.ETH_TESTNET;
405
259
  }
406
260
  }
407
261
  static getCarbonEvmNetworkParams(network) {
408
262
  switch (network) {
409
263
  case constant_1.Network.LocalHost:
410
- return CARBON_EVM_LOCALHOST;
264
+ return constant_2.CARBON_EVM_LOCALHOST;
411
265
  case constant_1.Network.DevNet:
412
- return CARBON_EVM_DEVNET;
266
+ return constant_2.CARBON_EVM_DEVNET;
413
267
  case constant_1.Network.TestNet:
414
- return CARBON_EVM_TESTNET;
268
+ return constant_2.CARBON_EVM_TESTNET;
415
269
  default:
416
- return CARBON_EVM_MAINNET;
270
+ return constant_2.CARBON_EVM_MAINNET;
417
271
  }
418
272
  }
419
273
  static getRequiredChainId(network, blockchain = 'Ethereum') {
@@ -467,7 +321,7 @@ class MetaMask {
467
321
  }
468
322
  syncBlockchain() {
469
323
  return __awaiter(this, void 0, void 0, function* () {
470
- const metamaskAPI = yield this.getAPI();
324
+ const metamaskAPI = yield this.getConnectedAPI();
471
325
  const chainIdHex = (yield (metamaskAPI === null || metamaskAPI === void 0 ? void 0 : metamaskAPI.request({ method: "eth_chainId" })));
472
326
  const chainId = chainIdHex ? parseInt(chainIdHex, 16) : undefined;
473
327
  const blockchain = blockchain_1.getBlockchainFromChainV2(chainId);
@@ -483,20 +337,20 @@ class MetaMask {
483
337
  }
484
338
  getAPI() {
485
339
  return __awaiter(this, void 0, void 0, function* () {
486
- return yield detect_provider_1.default();
340
+ return yield detect_provider_1.default({ mustBeMetaMask: true });
487
341
  });
488
342
  }
343
+ getMetaMaskProvider() {
344
+ const metamaskProvider = super.getProvider(constant_1.SupportedEip6963Provider.MetaMask);
345
+ return metamaskProvider === null || metamaskProvider === void 0 ? void 0 : metamaskProvider.provider;
346
+ }
489
347
  getConnectedAPI() {
490
348
  return __awaiter(this, void 0, void 0, function* () {
491
- const metamaskAPI = yield this.getAPI();
492
- if (!metamaskAPI) {
349
+ const metamaskProvider = this.getMetaMaskProvider();
350
+ if (!metamaskProvider) {
493
351
  throw new Error("MetaMask not connected, please check that your extension is enabled");
494
352
  }
495
- if (metamaskAPI === null || metamaskAPI === void 0 ? void 0 : metamaskAPI.isConnected()) {
496
- return metamaskAPI;
497
- }
498
- yield metamaskAPI.request({ method: "eth_requestAccounts" });
499
- return metamaskAPI;
353
+ return metamaskProvider;
500
354
  });
501
355
  }
502
356
  connect() {
@@ -1 +1 @@
1
- export { EVMChain, MetaMaskChangeNetworkParam, CallContractArgs, MetaMaskSyncResult, MetaMask } from "./MetaMask";
1
+ export { CallContractArgs, MetaMask } from "./MetaMask";
@@ -1,23 +1,19 @@
1
- import { CarbonSDK, EVMChain as EVMChainV2 } from "../../index";
1
+ import { CarbonSDK, SupportedEip6963Provider } from "../../index";
2
2
  import { CarbonSigner } from "../../wallet";
3
3
  import { ethers } from "ethers";
4
4
  import { StdFee } from "@cosmjs/stargate";
5
5
  import { SWTHAddressOptions } from "../../util/address";
6
6
  import { AminoMsg } from "@cosmjs/amino";
7
- import { Blockchain, BlockchainV2 } from "../../util/blockchain";
8
- import { Network } from "../../constant";
7
+ import { BlockchainV2 } from "../../util/blockchain";
8
+ import { EVMChain, Network, SyncResult } from "../../constant";
9
+ import { Eip6963Provider } from "../eip6963Provider";
9
10
  import { ChangeNetworkParam } from "../../constant";
10
11
  export interface RainbowKitWalletOpts {
11
12
  publicKeyMessage?: string;
12
13
  publicKeyBase64: string;
13
- walletProvider: string;
14
+ walletProvider: SupportedEip6963Provider;
14
15
  }
15
- export interface SyncResult {
16
- blockchain?: Blockchain | BlockchainV2;
17
- chainId?: number;
18
- }
19
- export declare type EVMChain = EVMChainV2;
20
- declare class RainbowKitAccount {
16
+ declare class RainbowKitAccount extends Eip6963Provider {
21
17
  readonly legacyEip712SignMode: boolean;
22
18
  private provider;
23
19
  private blockchain;
@@ -22,9 +22,11 @@ const legacyEIP712_1 = require("../../util/legacyEIP712");
22
22
  const network_1 = require("../../util/network");
23
23
  const blockchain_1 = require("../../util/blockchain");
24
24
  const constant_1 = require("../../constant");
25
+ const eip6963Provider_1 = require("../eip6963Provider");
25
26
  const constant_2 = require("../../constant");
26
- class RainbowKitAccount {
27
+ class RainbowKitAccount extends eip6963Provider_1.Eip6963Provider {
27
28
  constructor(provider, legacyEip712SignMode = false) {
29
+ super();
28
30
  this.legacyEip712SignMode = legacyEip712SignMode;
29
31
  this.blockchain = 'Ethereum';
30
32
  this.provider = provider;
@@ -119,6 +121,7 @@ class RainbowKitAccount {
119
121
  });
120
122
  return {
121
123
  type: wallet_1.CarbonSignerTypes.BrowserInjected,
124
+ legacyEip712SignMode: rainbowKit.legacyEip712SignMode,
122
125
  getAccounts,
123
126
  signDirect,
124
127
  sendEvmTransaction,
@@ -23,7 +23,7 @@ export declare class Zilpay {
23
23
  readonly network: Network;
24
24
  private blockchain;
25
25
  static getNetworkParams(network: Network): ZilPayChangeNetworkParam;
26
- static getRequiredChainId(network: Network): 1 | 333 | 888;
26
+ static getRequiredChainId(network: Network): 1 | 888 | 333;
27
27
  constructor(network: Network);
28
28
  getBlockchain(): BlockchainUtils.Blockchain;
29
29
  getSigner(): Promise<Signer>;
@@ -2,7 +2,7 @@
2
2
  import { OverrideConfig } from "../CarbonSDK";
3
3
  import { CarbonQueryClient } from "../clients";
4
4
  import GasFee from "../clients/GasFee";
5
- import { Network, NetworkConfig } from "../constant";
5
+ import { Network, NetworkConfig, SupportedEip6963Provider } from "../constant";
6
6
  import { ProviderAgent } from "../constant/walletProvider";
7
7
  import { ChainInfo, CosmosLedger, Keplr, MetaMask } from "../provider";
8
8
  import { CarbonTx } from "../util";
@@ -20,6 +20,7 @@ import { Key } from "@keplr-wallet/types";
20
20
  import { TxRaw as StargateTxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
21
21
  import { CarbonSigner, CarbonSignerTypes } from "./CarbonSigner";
22
22
  import { CarbonSigningClient } from "./CarbonSigningClient";
23
+ import RainbowKitAccount from "../provider/rainbowKit/RainbowKitAccount";
23
24
  export interface CarbonWalletGenericOpts {
24
25
  tmClient?: Tendermint37Client;
25
26
  txDefaultBroadcastMode?: BroadcastTxMode;
@@ -30,6 +31,7 @@ export interface CarbonWalletGenericOpts {
30
31
  disableRetryOnSequenceError?: boolean;
31
32
  triggerMerge?: boolean;
32
33
  gasFee?: GasFee;
34
+ isRainbowKit?: boolean;
33
35
  /**
34
36
  * Optional callback that will be called before signing is requested/executed.
35
37
  */
@@ -113,6 +115,7 @@ export declare class CarbonWallet {
113
115
  initialized: boolean;
114
116
  accountInfo?: AccountInfo;
115
117
  disableRetryOnSequenceError: boolean;
118
+ isRainbowKit: boolean;
116
119
  providerAgent?: ProviderAgent | string;
117
120
  authorizedMsgs?: string[];
118
121
  authorizedMsgsVersion?: number;
@@ -133,6 +136,7 @@ export declare class CarbonWallet {
133
136
  static withKeplr(keplr: Keplr, chainInfo: ChainInfo, keplrKey: Key, opts?: Omit<CarbonWalletInitOpts, "signer">): CarbonWallet;
134
137
  static withLeap(leap: Leap, chainId: string, leapKey: LeapKey, opts?: Omit<CarbonWalletInitOpts, "signer">): CarbonWallet;
135
138
  static withMetamask(metamask: MetaMask, evmChainId: string, compressedPubKeyBase64: string, addressOptions: SWTHAddressOptions, opts?: Omit<CarbonWalletInitOpts, "signer">): CarbonWallet;
139
+ static withRainbowKit(rainbowKit: RainbowKitAccount, evmChainId: string, compressedPubKeyBase64: string, addressOptions: SWTHAddressOptions, walletProvider: SupportedEip6963Provider, opts?: Omit<CarbonWalletInitOpts, "signer">): CarbonWallet;
136
140
  static withAddress(bech32Address: string, opts?: Partial<CarbonWalletInitOpts>): CarbonWallet;
137
141
  initialize(queryClient: CarbonQueryClient, gasFee: GasFee, fallbackConfig?: OverrideConfig | null): Promise<CarbonWallet>;
138
142
  setGrantee(grantee?: Grantee): void;
@@ -41,11 +41,13 @@ const dayjs_1 = __importDefault(require("dayjs"));
41
41
  const utc_1 = __importDefault(require("dayjs/plugin/utc"));
42
42
  const CarbonSigner_1 = require("./CarbonSigner");
43
43
  const CarbonSigningClient_1 = require("./CarbonSigningClient");
44
+ const RainbowKitAccount_1 = __importDefault(require("../provider/rainbowKit/RainbowKitAccount"));
44
45
  dayjs_1.default.extend(utc_1.default);
45
46
  class CarbonWallet {
46
47
  constructor(opts) {
47
- var _a, _b, _c, _d, _e;
48
+ var _a, _b, _c, _d, _e, _f;
48
49
  this.initialized = false;
50
+ this.isRainbowKit = false;
49
51
  this.sequenceInvalidated = false;
50
52
  this.isAccountNotFoundError = (error, address) => {
51
53
  var _a;
@@ -76,6 +78,7 @@ class CarbonWallet {
76
78
  this.triggerMerge = (_e = opts.triggerMerge) !== null && _e !== void 0 ? _e : false;
77
79
  this.gasFee = opts.gasFee;
78
80
  this.updateNetwork(network);
81
+ this.isRainbowKit = (_f = opts.isRainbowKit) !== null && _f !== void 0 ? _f : false;
79
82
  this.onRequestSign = opts.onRequestSign;
80
83
  this.onSignComplete = opts.onSignComplete;
81
84
  this.onBroadcastTxSuccess = opts.onBroadcastTxSuccess;
@@ -153,6 +156,11 @@ class CarbonWallet {
153
156
  const wallet = CarbonWallet.withSigner(signer, compressedPubKeyBase64, Object.assign({ providerAgent: walletProvider_1.ProviderAgent.MetamaskExtension }, opts));
154
157
  return wallet;
155
158
  }
159
+ static withRainbowKit(rainbowKit, evmChainId, compressedPubKeyBase64, addressOptions, walletProvider, opts = {}) {
160
+ const signer = RainbowKitAccount_1.default.createRainbowKitSigner(rainbowKit, evmChainId, compressedPubKeyBase64, addressOptions);
161
+ const wallet = CarbonWallet.withSigner(signer, compressedPubKeyBase64, Object.assign(Object.assign({}, opts), { providerAgent: walletProvider, isRainbowKit: true }));
162
+ return wallet;
163
+ }
156
164
  static withAddress(bech32Address, opts = {}) {
157
165
  return new CarbonWallet(Object.assign(Object.assign({}, opts), { bech32Address }));
158
166
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-js-sdk",
3
- "version": "0.11.1",
3
+ "version": "0.11.2-beta.1",
4
4
  "description": "TypeScript SDK for Carbon blockchain",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",