carbon-js-sdk 0.11.70 → 0.11.72
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.
- package/lib/CarbonSDK.d.ts +1 -7
- package/lib/CarbonSDK.js +0 -16
- package/lib/clients/index.d.ts +0 -2
- package/lib/clients/index.js +1 -5
- package/lib/constant/network.js +4 -5
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -5
- package/lib/provider/index.d.ts +0 -3
- package/lib/provider/index.js +1 -8
- package/lib/util/address.d.ts +0 -7
- package/lib/util/address.js +4 -89
- package/lib/wallet/CarbonWallet.js +0 -2
- package/package.json +5 -7
- package/lib/clients/N3Client.d.ts +0 -73
- package/lib/clients/N3Client.js +0 -285
- package/lib/clients/NEOClient.d.ts +0 -57
- package/lib/clients/NEOClient.js +0 -337
- package/lib/clients/ZILClient.d.ts +0 -106
- package/lib/clients/ZILClient.js +0 -437
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/BIP44.d.ts +0 -5
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/BIP44.js +0 -26
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.d.ts +0 -40
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +0 -62
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/index.d.ts +0 -3
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/index.js +0 -21
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.d.ts +0 -42
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +0 -181
- package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.d.ts +0 -24
- package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +0 -150
- package/lib/provider/account/NeoLedgerAccount/NeonLedger.d.ts +0 -59
- package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +0 -180
- package/lib/provider/account/NeoLedgerAccount/index.d.ts +0 -1
- package/lib/provider/account/NeoLedgerAccount/index.js +0 -17
- package/lib/provider/account/index.d.ts +0 -1
- package/lib/provider/account/index.js +0 -17
- package/lib/provider/o3/O3Types.d.ts +0 -84
- package/lib/provider/o3/O3Types.js +0 -41
- package/lib/provider/o3/O3Wallet.d.ts +0 -29
- package/lib/provider/o3/O3Wallet.js +0 -242
- package/lib/provider/o3/index.d.ts +0 -2
- package/lib/provider/o3/index.js +0 -32
- package/lib/provider/zilpay/Zilpay.d.ts +0 -33
- package/lib/provider/zilpay/Zilpay.js +0 -82
- package/lib/provider/zilpay/index.d.ts +0 -1
- package/lib/provider/zilpay/index.js +0 -17
package/lib/CarbonSDK.d.ts
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
import { Network, NetworkConfig, Network as _Network } from "./constant";
|
|
3
3
|
import { Tendermint37Client } from "@cosmjs/tendermint-rpc";
|
|
4
4
|
import * as clients from "./clients";
|
|
5
|
-
import { CarbonQueryClient, HydrogenClient, InsightsQueryClient,
|
|
5
|
+
import { CarbonQueryClient, HydrogenClient, InsightsQueryClient, TokenClient } from "./clients";
|
|
6
6
|
import GasFee from "./clients/GasFee";
|
|
7
7
|
import GrpcQueryClient from "./clients/GrpcQueryClient";
|
|
8
|
-
import N3Client from "./clients/N3Client";
|
|
9
8
|
import { AdminModule, AllianceModule, BankModule, BridgeModule, BrokerModule, CDPModule, CoinModule, ERC20Module, EvmMergeModule, EvmModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OTCModule, OracleModule, OrderModule, PerpspoolModule, PositionModule, ProfileModule, SubAccountModule, XChainModule } from "./modules";
|
|
10
9
|
import { GrantModule } from "./modules/grant";
|
|
11
10
|
import { StakingModule } from "./modules/staking";
|
|
@@ -100,9 +99,6 @@ declare class CarbonSDK {
|
|
|
100
99
|
evmmerge: EvmMergeModule;
|
|
101
100
|
bridge: BridgeModule;
|
|
102
101
|
otc: OTCModule;
|
|
103
|
-
neo: NEOClient;
|
|
104
|
-
zil: ZILClient;
|
|
105
|
-
n3: N3Client;
|
|
106
102
|
chainId: string;
|
|
107
103
|
evmChainId: string;
|
|
108
104
|
constructor(opts: CarbonSDKOpts);
|
|
@@ -150,8 +146,6 @@ declare namespace CarbonSDK {
|
|
|
150
146
|
export import ETHClient = clients.ETHClient;
|
|
151
147
|
export import HydrogenClient = clients.HydrogenClient;
|
|
152
148
|
export import InsightsQueryClient = clients.InsightsQueryClient;
|
|
153
|
-
export import NEOClient = clients.NEOClient;
|
|
154
149
|
export import TokenClient = clients.TokenClient;
|
|
155
|
-
export import ZILClient = clients.ZILClient;
|
|
156
150
|
}
|
|
157
151
|
export default CarbonSDK;
|
package/lib/CarbonSDK.js
CHANGED
|
@@ -44,14 +44,12 @@ const clients = __importStar(require("./clients"));
|
|
|
44
44
|
const clients_1 = require("./clients");
|
|
45
45
|
const GasFee_1 = __importDefault(require("./clients/GasFee"));
|
|
46
46
|
const GrpcQueryClient_1 = __importDefault(require("./clients/GrpcQueryClient"));
|
|
47
|
-
const N3Client_1 = __importDefault(require("./clients/N3Client"));
|
|
48
47
|
const modules_1 = require("./modules");
|
|
49
48
|
const grant_1 = require("./modules/grant");
|
|
50
49
|
const staking_1 = require("./modules/staking");
|
|
51
50
|
const provider_1 = require("./provider");
|
|
52
51
|
const MetaMask_1 = require("./provider/metamask/MetaMask");
|
|
53
52
|
const RainbowKitAccount_1 = __importDefault(require("./provider/rainbowKit/RainbowKitAccount"));
|
|
54
|
-
const blockchain_1 = require("./util/blockchain");
|
|
55
53
|
const number_1 = require("./util/number");
|
|
56
54
|
const wallet_1 = require("./wallet");
|
|
57
55
|
const auth_1 = require("./util/auth");
|
|
@@ -126,18 +124,6 @@ class CarbonSDK {
|
|
|
126
124
|
this.evmmerge = new modules_1.EvmMergeModule(this);
|
|
127
125
|
this.bridge = new modules_1.BridgeModule(this);
|
|
128
126
|
this.otc = new modules_1.OTCModule(this);
|
|
129
|
-
this.neo = clients_1.NEOClient.instance({
|
|
130
|
-
configProvider: this,
|
|
131
|
-
blockchain: blockchain_1.Blockchain.Neo,
|
|
132
|
-
});
|
|
133
|
-
this.n3 = N3Client_1.default.instance({
|
|
134
|
-
configProvider: this,
|
|
135
|
-
blockchain: blockchain_1.Blockchain.Neo3,
|
|
136
|
-
});
|
|
137
|
-
this.zil = clients_1.ZILClient.instance({
|
|
138
|
-
configProvider: this,
|
|
139
|
-
blockchain: blockchain_1.Blockchain.Zilliqa,
|
|
140
|
-
});
|
|
141
127
|
}
|
|
142
128
|
static instance(opts = DEFAULT_SDK_INIT_OPTS) {
|
|
143
129
|
var _a, _b, _c, _d;
|
|
@@ -472,8 +458,6 @@ exports.ConnectedCarbonSDK = ConnectedCarbonSDK;
|
|
|
472
458
|
CarbonSDK.ETHClient = clients.ETHClient;
|
|
473
459
|
CarbonSDK.HydrogenClient = clients.HydrogenClient;
|
|
474
460
|
CarbonSDK.InsightsQueryClient = clients.InsightsQueryClient;
|
|
475
|
-
CarbonSDK.NEOClient = clients.NEOClient;
|
|
476
461
|
CarbonSDK.TokenClient = clients.TokenClient;
|
|
477
|
-
CarbonSDK.ZILClient = clients.ZILClient;
|
|
478
462
|
})(CarbonSDK || (CarbonSDK = {}));
|
|
479
463
|
exports.default = CarbonSDK;
|
package/lib/clients/index.d.ts
CHANGED
|
@@ -4,6 +4,4 @@ export { default as CarbonQueryClient } from "./CarbonQueryClient";
|
|
|
4
4
|
export { default as ETHClient } from "./ETHClient";
|
|
5
5
|
export { default as HydrogenClient } from "./HydrogenClient";
|
|
6
6
|
export { default as InsightsQueryClient } from "./InsightsQueryClient";
|
|
7
|
-
export { default as NEOClient } from "./NEOClient";
|
|
8
7
|
export { default as TokenClient } from "./TokenClient";
|
|
9
|
-
export { default as ZILClient } from "./ZILClient";
|
package/lib/clients/index.js
CHANGED
|
@@ -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.
|
|
6
|
+
exports.TokenClient = exports.InsightsQueryClient = exports.HydrogenClient = exports.ETHClient = exports.CarbonQueryClient = exports.BlockchainClient = exports.BatchQueryClient = void 0;
|
|
7
7
|
var BatchQueryClient_1 = require("./BatchQueryClient");
|
|
8
8
|
Object.defineProperty(exports, "BatchQueryClient", { enumerable: true, get: function () { return __importDefault(BatchQueryClient_1).default; } });
|
|
9
9
|
var BlockchainClient_1 = require("./BlockchainClient");
|
|
@@ -16,9 +16,5 @@ var HydrogenClient_1 = require("./HydrogenClient");
|
|
|
16
16
|
Object.defineProperty(exports, "HydrogenClient", { enumerable: true, get: function () { return __importDefault(HydrogenClient_1).default; } });
|
|
17
17
|
var InsightsQueryClient_1 = require("./InsightsQueryClient");
|
|
18
18
|
Object.defineProperty(exports, "InsightsQueryClient", { enumerable: true, get: function () { return __importDefault(InsightsQueryClient_1).default; } });
|
|
19
|
-
var NEOClient_1 = require("./NEOClient");
|
|
20
|
-
Object.defineProperty(exports, "NEOClient", { enumerable: true, get: function () { return __importDefault(NEOClient_1).default; } });
|
|
21
19
|
var TokenClient_1 = require("./TokenClient");
|
|
22
20
|
Object.defineProperty(exports, "TokenClient", { enumerable: true, get: function () { return __importDefault(TokenClient_1).default; } });
|
|
23
|
-
var ZILClient_1 = require("./ZILClient");
|
|
24
|
-
Object.defineProperty(exports, "ZILClient", { enumerable: true, get: function () { return __importDefault(ZILClient_1).default; } });
|
package/lib/constant/network.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NetworkConfigs = exports.DEFAULT_NETWORK = exports.CarbonEvmChainIDs = exports.CarbonChainIDs = exports.Network = void 0;
|
|
4
|
-
const neon_core_next_1 = require("@cityofzion/neon-core-next");
|
|
5
4
|
var Network;
|
|
6
5
|
(function (Network) {
|
|
7
6
|
Network["MainNet"] = "mainnet";
|
|
@@ -99,7 +98,7 @@ exports.NetworkConfigs = {
|
|
|
99
98
|
},
|
|
100
99
|
n3: {
|
|
101
100
|
rpcURL: "https://n3-rpc.dem.exchange",
|
|
102
|
-
networkMagic:
|
|
101
|
+
networkMagic: 860833102,
|
|
103
102
|
},
|
|
104
103
|
zil: {
|
|
105
104
|
rpcURL: "https://api.zilliqa.com",
|
|
@@ -180,7 +179,7 @@ exports.NetworkConfigs = {
|
|
|
180
179
|
},
|
|
181
180
|
n3: {
|
|
182
181
|
rpcURL: "https://test-n3-rpc.dem.exchange",
|
|
183
|
-
networkMagic:
|
|
182
|
+
networkMagic: 877933390,
|
|
184
183
|
},
|
|
185
184
|
zil: {
|
|
186
185
|
rpcURL: "https://dev-api.zilliqa.com",
|
|
@@ -272,7 +271,7 @@ exports.NetworkConfigs = {
|
|
|
272
271
|
},
|
|
273
272
|
n3: {
|
|
274
273
|
rpcURL: "https://test-n3-rpc.dem.exchange",
|
|
275
|
-
networkMagic:
|
|
274
|
+
networkMagic: 877933390,
|
|
276
275
|
},
|
|
277
276
|
zil: {
|
|
278
277
|
rpcURL: "https://dev-api.zilliqa.com",
|
|
@@ -353,7 +352,7 @@ exports.NetworkConfigs = {
|
|
|
353
352
|
},
|
|
354
353
|
n3: {
|
|
355
354
|
rpcURL: "https://test-n3-rpc.dem.exchange",
|
|
356
|
-
networkMagic:
|
|
355
|
+
networkMagic: 877933390,
|
|
357
356
|
},
|
|
358
357
|
zil: {
|
|
359
358
|
rpcURL: "",
|
package/lib/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ 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, CallContractArgs, MetaMask,
|
|
7
|
+
export { AminoTypesMap, SDKProvider, KeplrAccount, KeplrWindow, CosmosLedger, Keplr, ChainInfo, CallContractArgs, MetaMask, LeapAccount, Leap, Key, getSigningCosmosClientOptions, AssetList, Chain, LeapExtended, RainbowKitAccount, Eip6963Provider, } from "./provider";
|
|
8
8
|
export { default as CarbonSDK } from "./CarbonSDK";
|
|
9
9
|
export { ProviderAgent, SupportedEip6963Provider, ChangeNetworkParam as MetaMaskChangeNetworkParam, EVMChain, SyncResult as MetaMaskSyncResult } from "./constant";
|
|
10
10
|
export * as Insights from "./insights";
|
package/lib/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
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.
|
|
32
|
+
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.MetaMask = exports.CosmosLedger = exports.KeplrAccount = exports.AminoTypesMap = exports.Blockchain = exports.Models = void 0;
|
|
33
33
|
__exportStar(require("./CarbonSDK"), exports);
|
|
34
34
|
__exportStar(require("./modules"), exports);
|
|
35
35
|
exports.Models = __importStar(require("./codec"));
|
|
@@ -42,10 +42,6 @@ Object.defineProperty(exports, "AminoTypesMap", { enumerable: true, get: functio
|
|
|
42
42
|
Object.defineProperty(exports, "KeplrAccount", { enumerable: true, get: function () { return provider_1.KeplrAccount; } });
|
|
43
43
|
Object.defineProperty(exports, "CosmosLedger", { enumerable: true, get: function () { return provider_1.CosmosLedger; } });
|
|
44
44
|
Object.defineProperty(exports, "MetaMask", { enumerable: true, get: function () { return provider_1.MetaMask; } });
|
|
45
|
-
Object.defineProperty(exports, "NeoLedgerAccount", { enumerable: true, get: function () { return provider_1.NeoLedgerAccount; } });
|
|
46
|
-
Object.defineProperty(exports, "Zilpay", { enumerable: true, get: function () { return provider_1.Zilpay; } });
|
|
47
|
-
Object.defineProperty(exports, "O3Types", { enumerable: true, get: function () { return provider_1.O3Types; } });
|
|
48
|
-
Object.defineProperty(exports, "O3Wallet", { enumerable: true, get: function () { return provider_1.O3Wallet; } });
|
|
49
45
|
Object.defineProperty(exports, "LeapAccount", { enumerable: true, get: function () { return provider_1.LeapAccount; } });
|
|
50
46
|
Object.defineProperty(exports, "getSigningCosmosClientOptions", { enumerable: true, get: function () { return provider_1.getSigningCosmosClientOptions; } });
|
|
51
47
|
Object.defineProperty(exports, "RainbowKitAccount", { enumerable: true, get: function () { return provider_1.RainbowKitAccount; } });
|
package/lib/provider/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
export { NeoLedgerAccount } from "./account";
|
|
2
1
|
export { AminoTypesMap } from "./amino";
|
|
3
2
|
export { ChainInfo, default as KeplrAccount, Keplr, KeplrWindow } from "./keplr";
|
|
4
3
|
export { default as LeapAccount, Leap, Key, LeapExtended } from "./leap";
|
|
5
4
|
export { default as CosmosLedger } from "./ledger";
|
|
6
5
|
export { CallContractArgs, MetaMask } from "./metamask";
|
|
7
6
|
export { EVMChain, SyncResult as MetaMaskSyncResult } from "../constant";
|
|
8
|
-
export { O3Types, O3Wallet } from "./o3";
|
|
9
7
|
export { default as SDKProvider } from "./sdk";
|
|
10
|
-
export { Zilpay, ZilPayChangeNetworkParam } from "./zilpay";
|
|
11
8
|
export { RainbowKitAccount } from './rainbowKit';
|
|
12
9
|
export { Eip6963Provider } from './eip6963Provider';
|
|
13
10
|
export { getSigningCosmosClientOptions, AssetList, Chain } from "./chainProvider";
|
package/lib/provider/index.js
CHANGED
|
@@ -3,9 +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.Eip6963Provider = exports.RainbowKitAccount = exports.
|
|
7
|
-
var account_1 = require("./account");
|
|
8
|
-
Object.defineProperty(exports, "NeoLedgerAccount", { enumerable: true, get: function () { return account_1.NeoLedgerAccount; } });
|
|
6
|
+
exports.getSigningCosmosClientOptions = exports.Eip6963Provider = exports.RainbowKitAccount = exports.MetaMask = exports.CosmosLedger = exports.LeapAccount = exports.KeplrAccount = exports.AminoTypesMap = void 0;
|
|
9
7
|
var amino_1 = require("./amino");
|
|
10
8
|
Object.defineProperty(exports, "AminoTypesMap", { enumerable: true, get: function () { return amino_1.AminoTypesMap; } });
|
|
11
9
|
var keplr_1 = require("./keplr");
|
|
@@ -16,11 +14,6 @@ var ledger_1 = require("./ledger");
|
|
|
16
14
|
Object.defineProperty(exports, "CosmosLedger", { enumerable: true, get: function () { return __importDefault(ledger_1).default; } });
|
|
17
15
|
var metamask_1 = require("./metamask");
|
|
18
16
|
Object.defineProperty(exports, "MetaMask", { enumerable: true, get: function () { return metamask_1.MetaMask; } });
|
|
19
|
-
var o3_1 = require("./o3");
|
|
20
|
-
Object.defineProperty(exports, "O3Types", { enumerable: true, get: function () { return o3_1.O3Types; } });
|
|
21
|
-
Object.defineProperty(exports, "O3Wallet", { enumerable: true, get: function () { return o3_1.O3Wallet; } });
|
|
22
|
-
var zilpay_1 = require("./zilpay");
|
|
23
|
-
Object.defineProperty(exports, "Zilpay", { enumerable: true, get: function () { return zilpay_1.Zilpay; } });
|
|
24
17
|
var rainbowKit_1 = require("./rainbowKit");
|
|
25
18
|
Object.defineProperty(exports, "RainbowKitAccount", { enumerable: true, get: function () { return rainbowKit_1.RainbowKitAccount; } });
|
|
26
19
|
var eip6963Provider_1 = require("./eip6963Provider");
|
package/lib/util/address.d.ts
CHANGED
|
@@ -65,13 +65,6 @@ type SWTHAddressType = AddressBuilder<SWTHAddressOptions> & {
|
|
|
65
65
|
getModuleAddress(moduleKey: string, network?: Network): string;
|
|
66
66
|
};
|
|
67
67
|
export declare const SWTHAddress: SWTHAddressType;
|
|
68
|
-
type NEOAddressType = AddressBuilder<AddressOptions> & {
|
|
69
|
-
isAddress(address: string): boolean;
|
|
70
|
-
encode(hash: string | Buffer, version?: string): string;
|
|
71
|
-
};
|
|
72
|
-
export declare const NEOAddress: NEOAddressType;
|
|
73
|
-
type N3AddressType = NEOAddressType & object;
|
|
74
|
-
export declare const N3Address: N3AddressType;
|
|
75
68
|
type ETHAddressType = AddressBuilder<AddressOptions> & {
|
|
76
69
|
encode(hash: string | Buffer, opts?: SWTHAddressOptions): string;
|
|
77
70
|
publicKeyToBech32Address(publicKey: string | Buffer, opts?: SWTHAddressOptions): string;
|
package/lib/util/address.js
CHANGED
|
@@ -26,21 +26,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.ETHAddress = exports.
|
|
29
|
+
exports.ETHAddress = exports.SWTHAddress = exports.wifEncodePrivateKey = exports.randomMnemonic = exports.BIP44Path = exports.stringOrBufferToBuffer = void 0;
|
|
30
30
|
const constant_1 = require("../constant");
|
|
31
|
-
const neon_core_next_1 = require("@cityofzion/neon-core-next");
|
|
32
|
-
const Base58Check = __importStar(require("base58check"));
|
|
33
31
|
const bech32 = __importStar(require("bech32"));
|
|
34
32
|
const BIP32 = __importStar(require("bip32"));
|
|
35
33
|
const BIP39 = __importStar(require("bip39"));
|
|
36
34
|
const crypto_js_1 = __importDefault(require("crypto-js"));
|
|
37
35
|
const ethers_1 = require("ethers");
|
|
38
36
|
const secp256k1 = __importStar(require("secp256k1"));
|
|
39
|
-
const secp256r1 = __importStar(require("secp256r1"));
|
|
40
37
|
const wif = __importStar(require("wif"));
|
|
41
38
|
const generic_1 = require("./generic");
|
|
42
39
|
const BIP44_PURPOSE = 44;
|
|
43
|
-
const NEO_COIN_TYPE = 0x00000378;
|
|
44
40
|
const ETH_COIN_TYPE = 0x0000003c;
|
|
45
41
|
const SWTH_COIN_TYPE = 118;
|
|
46
42
|
/**
|
|
@@ -139,9 +135,9 @@ exports.SWTHAddress = {
|
|
|
139
135
|
return privateKey;
|
|
140
136
|
},
|
|
141
137
|
privateToPublicKey: (privateKey) => {
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
const publicKey = Buffer.from(
|
|
138
|
+
const privateKeyArr = new Uint8Array((0, exports.stringOrBufferToBuffer)(privateKey));
|
|
139
|
+
const publicKeyArr = secp256k1.publicKeyCreate(privateKeyArr, true);
|
|
140
|
+
const publicKey = Buffer.from(publicKeyArr);
|
|
145
141
|
return publicKey;
|
|
146
142
|
},
|
|
147
143
|
privateKeyToAddress: (privateKey, opts) => {
|
|
@@ -196,87 +192,6 @@ exports.SWTHAddress = {
|
|
|
196
192
|
return exports.SWTHAddress.encode(addressHash, { network });
|
|
197
193
|
},
|
|
198
194
|
};
|
|
199
|
-
exports.NEOAddress = {
|
|
200
|
-
coinType: () => {
|
|
201
|
-
return NEO_COIN_TYPE;
|
|
202
|
-
},
|
|
203
|
-
publicKeyToScriptHash: (publicKey) => {
|
|
204
|
-
const encodedPublicKey = exports.NEOAddress.encodePublicKey(publicKey);
|
|
205
|
-
const addressScript = Buffer.concat([
|
|
206
|
-
Buffer.from([0x21]),
|
|
207
|
-
encodedPublicKey,
|
|
208
|
-
Buffer.from([0xac]), // OptCode.CHECKSIG
|
|
209
|
-
]);
|
|
210
|
-
const sha256Hash = ethers_1.ethers.utils.sha256(addressScript);
|
|
211
|
-
const ripemdHash = ethers_1.ethers.utils.ripemd160(sha256Hash);
|
|
212
|
-
return (0, generic_1.stripHexPrefix)(ripemdHash);
|
|
213
|
-
},
|
|
214
|
-
publicKeyToAddress: (publicKey) => {
|
|
215
|
-
const addressScript = exports.NEOAddress.publicKeyToScriptHash(publicKey);
|
|
216
|
-
const address = Base58Check.encode(addressScript, "17");
|
|
217
|
-
return address;
|
|
218
|
-
},
|
|
219
|
-
encodePublicKey: (unencodedPublicKey) => {
|
|
220
|
-
const unencPubKeyBuf = (0, exports.stringOrBufferToBuffer)(unencodedPublicKey);
|
|
221
|
-
if (unencPubKeyBuf.length <= 33) {
|
|
222
|
-
// length indicates already encoded
|
|
223
|
-
return unencPubKeyBuf;
|
|
224
|
-
}
|
|
225
|
-
const pointXHex = unencPubKeyBuf.slice(1, 33);
|
|
226
|
-
const pointYEven = unencPubKeyBuf[unencPubKeyBuf.length - 1] % 2 === 0;
|
|
227
|
-
const compressedPublicKey = Buffer.concat([Buffer.from([pointYEven ? 0x02 : 0x03]), pointXHex]);
|
|
228
|
-
return compressedPublicKey;
|
|
229
|
-
},
|
|
230
|
-
encode: (addressScript, version = "17") => {
|
|
231
|
-
return Base58Check.encode(addressScript, version);
|
|
232
|
-
},
|
|
233
|
-
mnemonicToPrivateKey: (mnemonic, account = 0) => {
|
|
234
|
-
const coinType = exports.NEOAddress.coinType();
|
|
235
|
-
const path = new BIP44Path(BIP44_PURPOSE, coinType).update(account).generate();
|
|
236
|
-
const seed = BIP39.mnemonicToSeedSync(mnemonic);
|
|
237
|
-
const masterKey = BIP32.fromSeed(seed);
|
|
238
|
-
const hardenedDerivation = masterKey.derivePath(path);
|
|
239
|
-
const privateKey = hardenedDerivation.privateKey;
|
|
240
|
-
if (!privateKey)
|
|
241
|
-
throw new Error("Private key derivation from mnemonic failed");
|
|
242
|
-
return privateKey;
|
|
243
|
-
},
|
|
244
|
-
privateToPublicKey: (privateKey) => {
|
|
245
|
-
const privateKeyBuff = (0, exports.stringOrBufferToBuffer)(privateKey);
|
|
246
|
-
const publicKeyUint8Array = secp256r1.publicKeyCreate(privateKeyBuff, true);
|
|
247
|
-
return Buffer.from(publicKeyUint8Array);
|
|
248
|
-
},
|
|
249
|
-
privateKeyToAddress: (privateKey) => {
|
|
250
|
-
const compressedPublicKey = exports.NEOAddress.privateToPublicKey(privateKey);
|
|
251
|
-
const address = exports.NEOAddress.publicKeyToAddress(compressedPublicKey);
|
|
252
|
-
return address;
|
|
253
|
-
},
|
|
254
|
-
generateAddress: (mnemonic, account = 0) => {
|
|
255
|
-
const privateKey = exports.NEOAddress.mnemonicToPrivateKey(mnemonic, account);
|
|
256
|
-
return exports.NEOAddress.privateKeyToAddress(privateKey);
|
|
257
|
-
},
|
|
258
|
-
isAddress: (address) => {
|
|
259
|
-
return neon_core_next_1.wallet.isAddress(address, 0x17);
|
|
260
|
-
},
|
|
261
|
-
};
|
|
262
|
-
exports.N3Address = Object.assign(Object.assign({}, exports.NEOAddress), { publicKeyToScriptHash: (publicKey) => {
|
|
263
|
-
const publicKeyHex = (0, exports.stringOrBufferToBuffer)(publicKey).toString("hex");
|
|
264
|
-
return neon_core_next_1.wallet.getScriptHashFromPublicKey(publicKeyHex);
|
|
265
|
-
}, publicKeyToAddress: (publicKey) => {
|
|
266
|
-
const addressScript = exports.N3Address.publicKeyToScriptHash(publicKey);
|
|
267
|
-
return neon_core_next_1.wallet.getAddressFromScriptHash(addressScript);
|
|
268
|
-
}, privateKeyToAddress: (privateKey) => {
|
|
269
|
-
const compressedPublicKey = exports.N3Address.privateToPublicKey(privateKey);
|
|
270
|
-
const address = exports.N3Address.publicKeyToAddress(compressedPublicKey);
|
|
271
|
-
return address;
|
|
272
|
-
}, generateAddress: (mnemonic, account = 0) => {
|
|
273
|
-
const privateKey = exports.N3Address.mnemonicToPrivateKey(mnemonic, account);
|
|
274
|
-
return exports.N3Address.privateKeyToAddress(privateKey);
|
|
275
|
-
}, isAddress: (address) => {
|
|
276
|
-
return neon_core_next_1.wallet.isAddress(address, neon_core_next_1.CONST.DEFAULT_ADDRESS_VERSION);
|
|
277
|
-
}, encode: (addressScript, version = "35") => {
|
|
278
|
-
return Base58Check.encode(addressScript, version);
|
|
279
|
-
} });
|
|
280
195
|
exports.ETHAddress = {
|
|
281
196
|
coinType: () => {
|
|
282
197
|
return ETH_COIN_TYPE;
|
|
@@ -671,8 +671,6 @@ class CarbonWallet {
|
|
|
671
671
|
case blockchain_1.SmartWalletBlockchain.Ethereum:
|
|
672
672
|
case blockchain_1.SmartWalletBlockchain.BinanceSmartChain:
|
|
673
673
|
return address_1.ETHAddress.mnemonicToPrivateKey(this.mnemonic);
|
|
674
|
-
case blockchain_1.SmartWalletBlockchain.Neo:
|
|
675
|
-
return address_1.NEOAddress.mnemonicToPrivateKey(this.mnemonic);
|
|
676
674
|
default:
|
|
677
675
|
return null;
|
|
678
676
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-js-sdk",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.72",
|
|
4
4
|
"description": "TypeScript SDK for Carbon blockchain",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"test": "tsc && node lib/test.js",
|
|
18
18
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
19
19
|
"lint": "eslint . --ext .ts",
|
|
20
|
-
"prepare": "yarn run build",
|
|
20
|
+
"prepare": "rm -rf ./lib && yarn run build",
|
|
21
21
|
"prepublishOnly": "yarn run lint",
|
|
22
22
|
"preversion": "yarn run lint",
|
|
23
23
|
"version": "yarn run format && git add -A src",
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"@ledgerhq/hw-transport-webhid": "^6.20.0",
|
|
49
49
|
"@ledgerhq/hw-transport-webusb": "^6.20.0",
|
|
50
50
|
"@metamask/detect-provider": "^2.0.0",
|
|
51
|
-
"@zilliqa-js/zilliqa": "^2.2.0",
|
|
52
51
|
"base58check": "^2.0.0",
|
|
53
52
|
"bignumber.js": "^9.1.0",
|
|
54
53
|
"bip32": "^2.0.6",
|
|
@@ -61,8 +60,6 @@
|
|
|
61
60
|
"jwt-decode": "^4.0.0",
|
|
62
61
|
"ledger-cosmos-js": "^2.1.8",
|
|
63
62
|
"lodash": "^4.17.21",
|
|
64
|
-
"neo-dapi": "^2.0.4",
|
|
65
|
-
"neo3-dapi": "^1.0.1",
|
|
66
63
|
"node-fetch": "^2.6.1",
|
|
67
64
|
"query-string": "^7.0.1",
|
|
68
65
|
"secp256k1": "^4.0.2",
|
|
@@ -90,5 +87,6 @@
|
|
|
90
87
|
"dotenv": "^10.0.0",
|
|
91
88
|
"eslint": "^8.42.0",
|
|
92
89
|
"prettier": "2.5.1"
|
|
93
|
-
}
|
|
94
|
-
|
|
90
|
+
},
|
|
91
|
+
"packageManager": "yarn@1.22.19"
|
|
92
|
+
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import CarbonSDK from "../CarbonSDK";
|
|
2
|
-
import { NetworkConfigProvider } from "../constant";
|
|
3
|
-
import { NeoLedgerAccount } from "../provider/account";
|
|
4
|
-
import { O3Wallet } from "../provider/o3";
|
|
5
|
-
import { Blockchain } from "../util/blockchain";
|
|
6
|
-
import { TokensWithExternalBalance } from "../util/external";
|
|
7
|
-
import { SimpleMap } from "../util/type";
|
|
8
|
-
import { tx, u } from "@cityofzion/neon-core-next";
|
|
9
|
-
import BigNumber from "bignumber.js";
|
|
10
|
-
export interface N3ClientOpts {
|
|
11
|
-
configProvider: NetworkConfigProvider;
|
|
12
|
-
blockchain?: Blockchain;
|
|
13
|
-
}
|
|
14
|
-
export interface LockLedgerDepositParams {
|
|
15
|
-
token: TokensWithExternalBalance;
|
|
16
|
-
toAddressHex: string;
|
|
17
|
-
feeAmount: BigNumber;
|
|
18
|
-
amount: BigNumber;
|
|
19
|
-
signCompleteCallback?: () => void;
|
|
20
|
-
ledger: NeoLedgerAccount;
|
|
21
|
-
}
|
|
22
|
-
export interface LockO3DepositParams {
|
|
23
|
-
token: TokensWithExternalBalance;
|
|
24
|
-
toAddressHex: string;
|
|
25
|
-
feeAmount: BigNumber;
|
|
26
|
-
amount: BigNumber;
|
|
27
|
-
signCompleteCallback?: () => void;
|
|
28
|
-
o3Wallet: O3Wallet;
|
|
29
|
-
}
|
|
30
|
-
export interface NeoDapiInvokeArgs {
|
|
31
|
-
scriptHash: string;
|
|
32
|
-
args?: any[];
|
|
33
|
-
operation: string;
|
|
34
|
-
fee?: string;
|
|
35
|
-
signers: any[];
|
|
36
|
-
}
|
|
37
|
-
export interface NeoDapiInvokeOutput {
|
|
38
|
-
txid: string;
|
|
39
|
-
nodeUrl: string;
|
|
40
|
-
}
|
|
41
|
-
export interface N3Signer {
|
|
42
|
-
scriptHash: string;
|
|
43
|
-
sign: (txn: tx.Transaction, networkMagic?: number, k?: string | number) => Promise<tx.Transaction>;
|
|
44
|
-
}
|
|
45
|
-
export declare class N3Client {
|
|
46
|
-
readonly configProvider: NetworkConfigProvider;
|
|
47
|
-
readonly blockchain: Blockchain;
|
|
48
|
-
static SUPPORTED_BLOCKCHAINS: Blockchain[];
|
|
49
|
-
static BLOCKCHAIN_KEY: {
|
|
50
|
-
neo3: string;
|
|
51
|
-
};
|
|
52
|
-
private rpcClient;
|
|
53
|
-
private constructor();
|
|
54
|
-
static signerFromPrivateKey(privateKey: string): N3Signer;
|
|
55
|
-
static signerFromLedger(ledger: NeoLedgerAccount): N3Signer;
|
|
56
|
-
static instance(opts: N3ClientOpts): N3Client;
|
|
57
|
-
getExternalBalances(sdk: CarbonSDK, address: string, whitelistDenoms?: string[]): Promise<TokensWithExternalBalance[]>;
|
|
58
|
-
getAllN3Balances(address: string): Promise<SimpleMap<string>>;
|
|
59
|
-
lock(lockProxyScriptHash: string, tokenScriptHash: string, fromAddressHex: string, toAddressHex: string, amount: BigNumber, feeAmount: BigNumber, signer: N3Signer): Promise<string | false>;
|
|
60
|
-
lockDeposit(token: TokensWithExternalBalance, feeAmountInput: string, swthAddress: string, neoPrivateKey: string): Promise<string | false>;
|
|
61
|
-
lockO3Deposit(params: LockO3DepositParams): Promise<string>;
|
|
62
|
-
lockLedgerDeposit(params: LockLedgerDepositParams): Promise<string | false>;
|
|
63
|
-
getNetworkFee(txn: tx.Transaction, networkFee: number): Promise<u.BigInteger>;
|
|
64
|
-
getSystemFee(txn: tx.Transaction, systemFee: number, signers?: (tx.Signer | tx.SignerJson)[]): Promise<u.BigInteger>;
|
|
65
|
-
formatWithdrawalAddress(address: string): string;
|
|
66
|
-
retrieveNEP17Info(address: string): Promise<{
|
|
67
|
-
name: string;
|
|
68
|
-
symbol: string;
|
|
69
|
-
address: string;
|
|
70
|
-
decimals: number;
|
|
71
|
-
}>;
|
|
72
|
-
}
|
|
73
|
-
export default N3Client;
|