@vleap/warps-adapter-near 0.1.0-beta.10 → 0.1.0-beta.12
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/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +101 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +114 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -140,8 +140,10 @@ declare class WarpNearWallet implements AdapterWarpWallet {
|
|
|
140
140
|
signMessage(message: string): Promise<string>;
|
|
141
141
|
sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
|
|
142
142
|
sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
importFromMnemonic(provider: WarpWalletProvider, mnemonic: string): Promise<WarpWalletDetails>;
|
|
144
|
+
importFromPrivateKey(provider: WarpWalletProvider, privateKey: string): Promise<WarpWalletDetails>;
|
|
145
|
+
export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
146
|
+
generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
145
147
|
getAddress(): string | null;
|
|
146
148
|
getPublicKey(): string | null;
|
|
147
149
|
private createProvider;
|
package/dist/index.d.ts
CHANGED
|
@@ -140,8 +140,10 @@ declare class WarpNearWallet implements AdapterWarpWallet {
|
|
|
140
140
|
signMessage(message: string): Promise<string>;
|
|
141
141
|
sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
|
|
142
142
|
sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
importFromMnemonic(provider: WarpWalletProvider, mnemonic: string): Promise<WarpWalletDetails>;
|
|
144
|
+
importFromPrivateKey(provider: WarpWalletProvider, privateKey: string): Promise<WarpWalletDetails>;
|
|
145
|
+
export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
146
|
+
generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
145
147
|
getAddress(): string | null;
|
|
146
148
|
getPublicKey(): string | null;
|
|
147
149
|
private createProvider;
|
package/dist/index.js
CHANGED
|
@@ -978,20 +978,48 @@ var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
|
978
978
|
getKeyPairInstance() {
|
|
979
979
|
return this.getKeyPair();
|
|
980
980
|
}
|
|
981
|
-
|
|
981
|
+
async importFromMnemonic(mnemonic) {
|
|
982
982
|
const seed = bip39.mnemonicToSeedSync(mnemonic);
|
|
983
983
|
const secretKey = seed.slice(0, 32);
|
|
984
984
|
const keyPair = import_near_api_js4.KeyPair.fromString(import_bs58.default.encode(secretKey));
|
|
985
985
|
const publicKey = keyPair.getPublicKey();
|
|
986
986
|
const accountId = (0, import_crypto.keyToImplicitAddress)(publicKey.toString());
|
|
987
|
-
|
|
987
|
+
const walletDetails = {
|
|
988
988
|
provider: _MnemonicWalletProvider.PROVIDER_NAME,
|
|
989
989
|
address: accountId,
|
|
990
|
-
privateKey:
|
|
990
|
+
privateKey: keyPair.toString(),
|
|
991
991
|
mnemonic
|
|
992
992
|
};
|
|
993
|
+
(0, import_warps5.setWarpWalletInConfig)(this.config, this.chain.name, walletDetails);
|
|
994
|
+
return walletDetails;
|
|
995
|
+
}
|
|
996
|
+
async importFromPrivateKey(privateKey) {
|
|
997
|
+
const keyPair = import_near_api_js4.KeyPair.fromString(privateKey);
|
|
998
|
+
const publicKey = keyPair.getPublicKey();
|
|
999
|
+
const accountId = (0, import_crypto.keyToImplicitAddress)(publicKey.toString());
|
|
1000
|
+
const walletDetails = {
|
|
1001
|
+
provider: _MnemonicWalletProvider.PROVIDER_NAME,
|
|
1002
|
+
address: accountId,
|
|
1003
|
+
privateKey: keyPair.toString(),
|
|
1004
|
+
mnemonic: null
|
|
1005
|
+
};
|
|
1006
|
+
(0, import_warps5.setWarpWalletInConfig)(this.config, this.chain.name, walletDetails);
|
|
1007
|
+
return walletDetails;
|
|
1008
|
+
}
|
|
1009
|
+
async export() {
|
|
1010
|
+
const keypair = this.getKeyPair();
|
|
1011
|
+
const mnemonic = (0, import_warps5.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
|
|
1012
|
+
const privateKey = (0, import_warps5.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
1013
|
+
const publicKey = keypair.getPublicKey();
|
|
1014
|
+
const accountId = (0, import_crypto.keyToImplicitAddress)(publicKey.toString());
|
|
1015
|
+
return {
|
|
1016
|
+
provider: _MnemonicWalletProvider.PROVIDER_NAME,
|
|
1017
|
+
address: accountId,
|
|
1018
|
+
privateKey: privateKey || null,
|
|
1019
|
+
mnemonic: mnemonic || null
|
|
1020
|
+
};
|
|
993
1021
|
}
|
|
994
|
-
generate() {
|
|
1022
|
+
async generate() {
|
|
995
1023
|
const mnemonic = bip39.generateMnemonic(import_english.wordlist);
|
|
996
1024
|
const seed = bip39.mnemonicToSeedSync(mnemonic);
|
|
997
1025
|
const secretKey = seed.slice(0, 32);
|
|
@@ -1063,20 +1091,48 @@ var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
|
|
|
1063
1091
|
getKeyPairInstance() {
|
|
1064
1092
|
return this.getKeyPair();
|
|
1065
1093
|
}
|
|
1066
|
-
|
|
1094
|
+
async importFromMnemonic(mnemonic) {
|
|
1067
1095
|
const seed = bip392.mnemonicToSeedSync(mnemonic);
|
|
1068
1096
|
const secretKey = seed.slice(0, 32);
|
|
1069
1097
|
const keyPair = import_near_api_js5.KeyPair.fromString(import_bs582.default.encode(secretKey));
|
|
1070
1098
|
const publicKey = keyPair.getPublicKey();
|
|
1071
1099
|
const accountId = (0, import_crypto2.keyToImplicitAddress)(publicKey.toString());
|
|
1072
|
-
|
|
1100
|
+
const walletDetails = {
|
|
1101
|
+
provider: _PrivateKeyWalletProvider.PROVIDER_NAME,
|
|
1102
|
+
address: accountId,
|
|
1103
|
+
privateKey: keyPair.toString(),
|
|
1104
|
+
mnemonic
|
|
1105
|
+
};
|
|
1106
|
+
(0, import_warps6.setWarpWalletInConfig)(this.config, this.chain.name, walletDetails);
|
|
1107
|
+
return walletDetails;
|
|
1108
|
+
}
|
|
1109
|
+
async importFromPrivateKey(privateKey) {
|
|
1110
|
+
const keyPair = import_near_api_js5.KeyPair.fromString(privateKey);
|
|
1111
|
+
const publicKey = keyPair.getPublicKey();
|
|
1112
|
+
const accountId = (0, import_crypto2.keyToImplicitAddress)(publicKey.toString());
|
|
1113
|
+
const walletDetails = {
|
|
1073
1114
|
provider: _PrivateKeyWalletProvider.PROVIDER_NAME,
|
|
1074
1115
|
address: accountId,
|
|
1075
1116
|
privateKey: keyPair.toString(),
|
|
1076
1117
|
mnemonic: null
|
|
1077
1118
|
};
|
|
1119
|
+
(0, import_warps6.setWarpWalletInConfig)(this.config, this.chain.name, walletDetails);
|
|
1120
|
+
return walletDetails;
|
|
1121
|
+
}
|
|
1122
|
+
async export() {
|
|
1123
|
+
const keypair = this.getKeyPair();
|
|
1124
|
+
const privateKey = (0, import_warps6.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
1125
|
+
const mnemonic = (0, import_warps6.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
|
|
1126
|
+
const publicKey = keypair.getPublicKey();
|
|
1127
|
+
const accountId = (0, import_crypto2.keyToImplicitAddress)(publicKey.toString());
|
|
1128
|
+
return {
|
|
1129
|
+
provider: _PrivateKeyWalletProvider.PROVIDER_NAME,
|
|
1130
|
+
address: accountId,
|
|
1131
|
+
privateKey: privateKey || null,
|
|
1132
|
+
mnemonic: mnemonic || null
|
|
1133
|
+
};
|
|
1078
1134
|
}
|
|
1079
|
-
generate() {
|
|
1135
|
+
async generate() {
|
|
1080
1136
|
const keyPair = import_near_api_js5.KeyPair.fromRandom("ed25519");
|
|
1081
1137
|
const publicKey = keyPair.getPublicKey();
|
|
1082
1138
|
const accountId = (0, import_crypto2.keyToImplicitAddress)(publicKey.toString());
|
|
@@ -1125,11 +1181,19 @@ var ReadOnlyWalletProvider = class {
|
|
|
1125
1181
|
const address = await this.getAddress();
|
|
1126
1182
|
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
1127
1183
|
}
|
|
1128
|
-
|
|
1184
|
+
async importFromMnemonic(mnemonic) {
|
|
1129
1185
|
const address = (0, import_warps7.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
1130
1186
|
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
1131
1187
|
}
|
|
1132
|
-
|
|
1188
|
+
async importFromPrivateKey(privateKey) {
|
|
1189
|
+
const address = (0, import_warps7.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
1190
|
+
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
1191
|
+
}
|
|
1192
|
+
async export() {
|
|
1193
|
+
const address = (0, import_warps7.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
1194
|
+
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
1195
|
+
}
|
|
1196
|
+
async generate() {
|
|
1133
1197
|
const address = (0, import_warps7.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
1134
1198
|
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
1135
1199
|
}
|
|
@@ -1214,13 +1278,21 @@ var WarpNearWallet = class {
|
|
|
1214
1278
|
async sendTransactions(txs) {
|
|
1215
1279
|
return Promise.all(txs.map(async (tx) => this.sendTransaction(tx)));
|
|
1216
1280
|
}
|
|
1217
|
-
|
|
1281
|
+
async importFromMnemonic(provider, mnemonic) {
|
|
1218
1282
|
const walletProvider = this.createProviderForOperation(provider);
|
|
1219
|
-
return walletProvider.
|
|
1283
|
+
return await walletProvider.importFromMnemonic(mnemonic);
|
|
1220
1284
|
}
|
|
1221
|
-
|
|
1285
|
+
async importFromPrivateKey(provider, privateKey) {
|
|
1222
1286
|
const walletProvider = this.createProviderForOperation(provider);
|
|
1223
|
-
return walletProvider.
|
|
1287
|
+
return await walletProvider.importFromPrivateKey(privateKey);
|
|
1288
|
+
}
|
|
1289
|
+
async export(provider) {
|
|
1290
|
+
const walletProvider = this.createProviderForOperation(provider);
|
|
1291
|
+
return await walletProvider.export();
|
|
1292
|
+
}
|
|
1293
|
+
async generate(provider) {
|
|
1294
|
+
const walletProvider = this.createProviderForOperation(provider);
|
|
1295
|
+
return await walletProvider.generate();
|
|
1224
1296
|
}
|
|
1225
1297
|
getAddress() {
|
|
1226
1298
|
return this.cachedAddress;
|
|
@@ -1281,7 +1353,10 @@ var NativeTokenNear = {
|
|
|
1281
1353
|
symbol: "NEAR",
|
|
1282
1354
|
name: "NEAR",
|
|
1283
1355
|
decimals: 24,
|
|
1284
|
-
logoUrl:
|
|
1356
|
+
logoUrl: {
|
|
1357
|
+
light: "https://joai.ai/images/tokens/near-white.svg",
|
|
1358
|
+
dark: "https://joai.ai/images/tokens/near-black.svg"
|
|
1359
|
+
}
|
|
1285
1360
|
};
|
|
1286
1361
|
var NearAdapter = createNearAdapter("near", {
|
|
1287
1362
|
mainnet: {
|
|
@@ -1291,7 +1366,10 @@ var NearAdapter = createNearAdapter("near", {
|
|
|
1291
1366
|
blockTime: 1200,
|
|
1292
1367
|
addressHrp: "",
|
|
1293
1368
|
defaultApiUrl: "https://rpc.mainnet.near.org",
|
|
1294
|
-
logoUrl:
|
|
1369
|
+
logoUrl: {
|
|
1370
|
+
light: "https://joai.ai/images/chains/near-white.svg",
|
|
1371
|
+
dark: "https://joai.ai/images/chains/near-black.svg"
|
|
1372
|
+
},
|
|
1295
1373
|
nativeToken: NativeTokenNear
|
|
1296
1374
|
},
|
|
1297
1375
|
testnet: {
|
|
@@ -1301,7 +1379,10 @@ var NearAdapter = createNearAdapter("near", {
|
|
|
1301
1379
|
blockTime: 1200,
|
|
1302
1380
|
addressHrp: "",
|
|
1303
1381
|
defaultApiUrl: "https://rpc.testnet.near.org",
|
|
1304
|
-
logoUrl:
|
|
1382
|
+
logoUrl: {
|
|
1383
|
+
light: "https://joai.ai/images/chains/near-white.svg",
|
|
1384
|
+
dark: "https://joai.ai/images/chains/near-black.svg"
|
|
1385
|
+
},
|
|
1305
1386
|
nativeToken: NativeTokenNear
|
|
1306
1387
|
},
|
|
1307
1388
|
devnet: {
|
|
@@ -1311,7 +1392,10 @@ var NearAdapter = createNearAdapter("near", {
|
|
|
1311
1392
|
blockTime: 1200,
|
|
1312
1393
|
addressHrp: "",
|
|
1313
1394
|
defaultApiUrl: "https://rpc.testnet.near.org",
|
|
1314
|
-
logoUrl:
|
|
1395
|
+
logoUrl: {
|
|
1396
|
+
light: "https://joai.ai/images/chains/near-white.svg",
|
|
1397
|
+
dark: "https://joai.ai/images/chains/near-black.svg"
|
|
1398
|
+
},
|
|
1315
1399
|
nativeToken: NativeTokenNear
|
|
1316
1400
|
}
|
|
1317
1401
|
});
|