@kynesyslabs/demosdk 1.0.21 → 1.0.22
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/build/encryption/Cryptography.d.ts +18 -1
- package/build/encryption/Cryptography.js +182 -1
- package/build/encryption/Cryptography.js.map +1 -1
- package/build/encryption/Hashing.d.ts +1 -1
- package/build/encryption/Hashing.js +2 -1
- package/build/encryption/Hashing.js.map +1 -1
- package/build/encryption/index.d.ts +2 -2
- package/build/encryption/index.js +4 -2
- package/build/encryption/index.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/multichain/core/solana.d.ts +16 -29
- package/build/multichain/core/solana.js +40 -126
- package/build/multichain/core/solana.js.map +1 -1
- package/build/multichain/core/types/defaultChain.d.ts +0 -18
- package/build/multichain/localsdk/index.d.ts +5 -4
- package/build/multichain/localsdk/index.js +3 -1
- package/build/multichain/localsdk/index.js.map +1 -1
- package/build/multichain/localsdk/solana.d.ts +1 -3
- package/build/multichain/localsdk/solana.js +5 -10
- package/build/multichain/localsdk/solana.js.map +1 -1
- package/build/multichain/websdk/index.d.ts +1 -0
- package/build/multichain/websdk/index.js +3 -1
- package/build/multichain/websdk/index.js.map +1 -1
- package/build/multichain/websdk/solana.d.ts +4 -0
- package/build/multichain/websdk/solana.js +11 -0
- package/build/multichain/websdk/solana.js.map +1 -0
- package/build/types/blockchain/Confirmation.d.ts +9 -0
- package/build/types/blockchain/Confirmation.js +23 -0
- package/build/types/blockchain/Confirmation.js.map +1 -0
- package/build/types/blockchain/WalletTypes.d.ts +3 -0
- package/build/types/blockchain/WalletTypes.js +3 -0
- package/build/types/blockchain/WalletTypes.js.map +1 -0
- package/build/utils/getRemoteIP.d.ts +1 -0
- package/build/utils/getRemoteIP.js +19 -0
- package/build/utils/getRemoteIP.js.map +1 -0
- package/build/wallet/Wallet.d.ts +25 -0
- package/build/wallet/Wallet.js +94 -0
- package/build/wallet/Wallet.js.map +1 -0
- package/build/wallet/index.d.ts +1 -0
- package/build/wallet/index.js +28 -0
- package/build/wallet/index.js.map +1 -0
- package/build/websdk/DemosTransactions.d.ts +1 -1
- package/build/websdk/DemosTransactions.js +3 -2
- package/build/websdk/DemosTransactions.js.map +1 -1
- package/build/websdk/demos.d.ts +2 -2
- package/package.json +55 -57
- package/.eslintignore +0 -6
- package/.eslintrc.cjs +0 -31
- package/.gitattributes +0 -4
- package/.github/workflows/publish.yml +0 -43
- package/.github/workflows/test:multichain.yml +0 -35
- package/.gitignore +0 -8
- package/.prettierrc +0 -13
- package/build/tests/multichain/chainProviders.d.ts +0 -29
- package/build/tests/multichain/chainProviders.js +0 -34
- package/build/tests/multichain/chainProviders.js.map +0 -1
- package/build/tests/multichain/evm.test.d.ts +0 -1
- package/build/tests/multichain/evm.test.js +0 -53
- package/build/tests/multichain/evm.test.js.map +0 -1
- package/build/tests/multichain/ibc.test.d.ts +0 -1
- package/build/tests/multichain/ibc.test.js +0 -74
- package/build/tests/multichain/ibc.test.js.map +0 -1
- package/build/tests/multichain/index.d.ts +0 -1
- package/build/tests/multichain/index.js +0 -94
- package/build/tests/multichain/index.js.map +0 -1
- package/build/tests/multichain/multiversx.test.d.ts +0 -1
- package/build/tests/multichain/multiversx.test.js +0 -49
- package/build/tests/multichain/multiversx.test.js.map +0 -1
- package/build/tests/multichain/solana.spec.d.ts +0 -1
- package/build/tests/multichain/solana.spec.js +0 -50
- package/build/tests/multichain/solana.spec.js.map +0 -1
- package/build/tests/multichain/template.test.d.ts +0 -0
- package/build/tests/multichain/template.test.js +0 -33
- package/build/tests/multichain/template.test.js.map +0 -1
- package/build/tests/multichain/xrpl.test.d.ts +0 -1
- package/build/tests/multichain/xrpl.test.js +0 -57
- package/build/tests/multichain/xrpl.test.js.map +0 -1
- package/build/tests/utils/index.d.ts +0 -14
- package/build/tests/utils/index.js +0 -34
- package/build/tests/utils/index.js.map +0 -1
- package/build/tests/utils/wallets.d.ts +0 -21
- package/build/tests/utils/wallets.js +0 -48
- package/build/tests/utils/wallets.js.map +0 -1
- package/build/tests/utils.test.d.ts +0 -1
- package/build/tests/utils.test.js +0 -19
- package/build/tests/utils.test.js.map +0 -1
- package/documentation/multichain/README.md +0 -85
- package/documentation/multichain/ibc.md +0 -3
- package/documentation/multichain/solana.md +0 -13
- package/jest.config.ts +0 -20
- package/src/encryption/Cryptography.ts +0 -128
- package/src/encryption/FHE/index.ts +0 -35
- package/src/encryption/Hashing.ts +0 -20
- package/src/encryption/PQC/index.ts +0 -260
- package/src/encryption/index.ts +0 -5
- package/src/encryption/zK/index.ts +0 -1
- package/src/encryption/zK/interactive/index.ts +0 -47
- package/src/encryption/zK/primer.ts +0 -71
- package/src/index.ts +0 -8
- package/src/multichain/archive/btc.ts +0 -72
- package/src/multichain/archive/demos.ts +0 -51
- package/src/multichain/archive/tron.ts +0 -86
- package/src/multichain/archive/xlm.ts +0 -65
- package/src/multichain/core/README.md +0 -1
- package/src/multichain/core/evm.ts +0 -275
- package/src/multichain/core/ibc.ts +0 -318
- package/src/multichain/core/index.ts +0 -29
- package/src/multichain/core/multiversx.ts +0 -310
- package/src/multichain/core/solana.ts +0 -336
- package/src/multichain/core/types/defaultChain.ts +0 -254
- package/src/multichain/core/types/interfaces.ts +0 -102
- package/src/multichain/core/utils.ts +0 -22
- package/src/multichain/core/xrp.ts +0 -253
- package/src/multichain/index.ts +0 -3
- package/src/multichain/localsdk/README.md +0 -1
- package/src/multichain/localsdk/evm.ts +0 -77
- package/src/multichain/localsdk/ibc.ts +0 -25
- package/src/multichain/localsdk/index.ts +0 -4
- package/src/multichain/localsdk/multiversx.ts +0 -66
- package/src/multichain/localsdk/solana.ts +0 -37
- package/src/multichain/localsdk/xrp.ts +0 -56
- package/src/multichain/websdk/README.md +0 -1
- package/src/multichain/websdk/evm.ts +0 -9
- package/src/multichain/websdk/ibc.ts +0 -10
- package/src/multichain/websdk/index.ts +0 -4
- package/src/multichain/websdk/multiversx.ts +0 -84
- package/src/multichain/websdk/xrp.ts +0 -9
- package/src/tests/multichain/chainProviders.ts +0 -32
- package/src/tests/multichain/evm.test.ts +0 -64
- package/src/tests/multichain/ibc.test.ts +0 -93
- package/src/tests/multichain/index.ts +0 -105
- package/src/tests/multichain/multiversx.test.ts +0 -57
- package/src/tests/multichain/solana.spec.ts +0 -56
- package/src/tests/multichain/template.test.ts +0 -37
- package/src/tests/multichain/xrpl.test.ts +0 -71
- package/src/tests/utils/index.ts +0 -34
- package/src/tests/utils/wallets.ts +0 -46
- package/src/tests/utils.test.ts +0 -21
- package/src/types/blockchain/ISignature.ts +0 -6
- package/src/types/blockchain/Transaction.ts +0 -34
- package/src/types/blockchain/TxFee.ts +0 -5
- package/src/types/blockchain/ValidityData.ts +0 -15
- package/src/types/blockchain/addressInfo.ts +0 -7
- package/src/types/blockchain/blocks.ts +0 -29
- package/src/types/blockchain/genesisTypes.ts +0 -39
- package/src/types/blockchain/rawTransaction.ts +0 -27
- package/src/types/blockchain/statusNative.ts +0 -6
- package/src/types/blockchain/statusProperties.ts +0 -8
- package/src/types/communication/transmit.ts +0 -27
- package/src/types/gls/Operation.ts +0 -25
- package/src/types/gls/StateChange.ts +0 -33
- package/src/types/index.ts +0 -60
- package/src/types/network/ExecutionResult.ts +0 -9
- package/src/types/network/SecurityTypes.ts +0 -18
- package/src/types/peers/Peer.ts +0 -18
- package/src/types/web2/index.ts +0 -76
- package/src/types/xm/index.ts +0 -21
- package/src/utils/dataManipulation.ts +0 -37
- package/src/utils/index.ts +0 -1
- package/src/websdk/DemosTransactions.ts +0 -74
- package/src/websdk/DemosWebAuth.ts +0 -186
- package/src/websdk/Web2Transactions.ts +0 -41
- package/src/websdk/XMTransactions.ts +0 -140
- package/src/websdk/demos.ts +0 -461
- package/src/websdk/index.ts +0 -15
- package/src/websdk/rsa.ts +0 -85
- package/src/websdk/types/IBuffer.ts +0 -4
- package/src/websdk/types/KeyPair.ts +0 -9
- package/src/websdk/utils/bufferizer.ts +0 -16
- package/src/websdk/utils/forge_converter.ts +0 -72
- package/src/websdk/utils/required.ts +0 -44
- package/src/websdk/utils/sha256.ts +0 -13
- package/src/websdk/utils/skeletons.ts +0 -69
- package/tsconfig.json +0 -34
- package/yarn.lock +0 -3705
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import forge from "node-forge";
|
|
2
|
-
export
|
|
2
|
+
export declare class Cryptography {
|
|
3
|
+
static new(): {
|
|
4
|
+
publicKey: forge.pki.ed25519.NativeBuffer;
|
|
5
|
+
privateKey: forge.pki.ed25519.NativeBuffer;
|
|
6
|
+
};
|
|
7
|
+
static newFromSeed(stringSeed: string): {
|
|
8
|
+
publicKey: forge.pki.ed25519.NativeBuffer;
|
|
9
|
+
privateKey: forge.pki.ed25519.NativeBuffer;
|
|
10
|
+
};
|
|
11
|
+
static save(keypair: forge.pki.KeyPair, path: string, mode?: string): Promise<void>;
|
|
12
|
+
static saveToHex(forgeBuffer: forge.pki.PrivateKey): string;
|
|
13
|
+
static saveEncrypted(keypair: forge.pki.KeyPair, path: string, password: string): Promise<void>;
|
|
14
|
+
static loadEncrypted(path: string, password: string): Promise<forge.pki.KeyPair>;
|
|
15
|
+
static load(path: string, isFile?: boolean): Promise<forge.pki.KeyPair>;
|
|
16
|
+
static loadFromHex(content: string): forge.pki.KeyPair;
|
|
17
|
+
static loadFromBufferString(content: string): forge.pki.KeyPair;
|
|
18
|
+
static sign(message: string, privateKey: forge.pki.ed25519.BinaryBuffer | any): forge.pki.ed25519.NativeBuffer;
|
|
19
|
+
static verify(signed: string, signature: any | forge.pki.ed25519.BinaryBuffer, publicKey: any | forge.pki.ed25519.BinaryBuffer): boolean;
|
|
3
20
|
static ed25519: {
|
|
4
21
|
sign: (message: string, privateKey: forge.pki.ed25519.BinaryBuffer | any) => forge.pki.ed25519.NativeBuffer;
|
|
5
22
|
verify: (signed: string, signature: any | forge.pki.ed25519.BinaryBuffer, publicKey: any | forge.pki.ed25519.BinaryBuffer) => boolean;
|
|
@@ -9,15 +9,197 @@ Human readable license: https://creativecommons.org/licenses/by-nc-nd/4.0/
|
|
|
9
9
|
KyneSys Labs: https://www.kynesys.xyz/
|
|
10
10
|
|
|
11
11
|
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
12
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
37
|
};
|
|
15
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Cryptography = void 0;
|
|
40
|
+
const crypto = __importStar(require("crypto"));
|
|
41
|
+
const fs_1 = require("fs");
|
|
16
42
|
const node_forge_1 = __importDefault(require("node-forge"));
|
|
17
43
|
const dataManipulation_1 = require("../utils/dataManipulation");
|
|
18
44
|
const algorithm = "aes-256-cbc";
|
|
19
45
|
class Cryptography {
|
|
46
|
+
static new() {
|
|
47
|
+
const seed = node_forge_1.default.random.getBytesSync(32);
|
|
48
|
+
const keys = node_forge_1.default.pki.ed25519.generateKeyPair({ seed });
|
|
49
|
+
console.log("Generated new keypair");
|
|
50
|
+
return keys;
|
|
51
|
+
}
|
|
52
|
+
// INFO Method to generate a new key pair from a seed
|
|
53
|
+
static newFromSeed(stringSeed) {
|
|
54
|
+
return node_forge_1.default.pki.ed25519.generateKeyPair({ seed: stringSeed });
|
|
55
|
+
}
|
|
56
|
+
// TODO Eliminate the old legacy compatibility
|
|
57
|
+
static async save(keypair, path, mode = "hex") {
|
|
58
|
+
console.log(keypair.privateKey);
|
|
59
|
+
if (mode === "hex") {
|
|
60
|
+
let hexPrivKey = Cryptography.saveToHex(keypair.privateKey);
|
|
61
|
+
await fs_1.promises.writeFile(path, hexPrivKey);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
await fs_1.promises.writeFile(path, JSON.stringify(keypair.privateKey));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
static saveToHex(forgeBuffer) {
|
|
68
|
+
console.log("[forge to string encoded]");
|
|
69
|
+
//console.log(forgeBuffer) // REVIEW if it is like this
|
|
70
|
+
let stringBuffer = forgeBuffer.toString("hex");
|
|
71
|
+
console.log("DECODED INTO:");
|
|
72
|
+
console.log("0x" + stringBuffer);
|
|
73
|
+
return "0x" + stringBuffer;
|
|
74
|
+
}
|
|
75
|
+
// SECTION Encrypted save and load
|
|
76
|
+
static async saveEncrypted(keypair, path, password) {
|
|
77
|
+
const key = crypto.createCipher(algorithm, password);
|
|
78
|
+
// Getting the private key in hex form
|
|
79
|
+
const hex_key = keypair.privateKey.toString("hex");
|
|
80
|
+
// Encrypting and saving
|
|
81
|
+
const encryptedMessage = key.update(hex_key, "utf8", "hex");
|
|
82
|
+
await fs_1.promises.writeFile(path, encryptedMessage);
|
|
83
|
+
}
|
|
84
|
+
static async loadEncrypted(path, password) {
|
|
85
|
+
let keypair = {
|
|
86
|
+
privateKey: null,
|
|
87
|
+
publicKey: null,
|
|
88
|
+
};
|
|
89
|
+
// Preparing the environment
|
|
90
|
+
const decipher = crypto.createDecipher(algorithm, password);
|
|
91
|
+
const contentOfFile = await fs_1.promises.readFile(path, "utf8");
|
|
92
|
+
// Decrypting
|
|
93
|
+
const decryptedKey = decipher.update(contentOfFile, "hex", "utf8");
|
|
94
|
+
// Loading
|
|
95
|
+
if (decryptedKey.includes("{")) {
|
|
96
|
+
keypair = Cryptography.loadFromBufferString(contentOfFile);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
keypair = Cryptography.loadFromHex(contentOfFile);
|
|
100
|
+
}
|
|
101
|
+
return keypair;
|
|
102
|
+
}
|
|
103
|
+
// !SECTION Encrypted save and load
|
|
104
|
+
// NOTE Accepts both file paths and strings being either hex or buffer strings
|
|
105
|
+
static async load(path, isFile = true) {
|
|
106
|
+
let keypair = {
|
|
107
|
+
privateKey: null,
|
|
108
|
+
publicKey: null,
|
|
109
|
+
};
|
|
110
|
+
let content;
|
|
111
|
+
if (isFile) {
|
|
112
|
+
content = await fs_1.promises.readFile(path, "utf8");
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
content = path;
|
|
116
|
+
}
|
|
117
|
+
if (content.includes("{")) {
|
|
118
|
+
keypair = Cryptography.loadFromBufferString(content);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
keypair = Cryptography.loadFromHex(content);
|
|
122
|
+
}
|
|
123
|
+
return keypair;
|
|
124
|
+
}
|
|
125
|
+
static loadFromHex(content) {
|
|
126
|
+
let keypair = { publicKey: null, privateKey: null };
|
|
127
|
+
content = content.slice(2);
|
|
128
|
+
let finalArray = new Uint8Array(64);
|
|
129
|
+
console.log("[string to forge encoded]");
|
|
130
|
+
console.log(content);
|
|
131
|
+
for (let i = 0; i < content.length; i += 2) {
|
|
132
|
+
const hexValue = content.substr(i, 2);
|
|
133
|
+
const decimalValue = parseInt(hexValue, 16);
|
|
134
|
+
finalArray[i / 2] = decimalValue;
|
|
135
|
+
}
|
|
136
|
+
console.log("ENCODED INTO:");
|
|
137
|
+
//console.log(finalArray)
|
|
138
|
+
// Condensing
|
|
139
|
+
console.log("That means:");
|
|
140
|
+
keypair.privateKey = Buffer.from(finalArray);
|
|
141
|
+
console.log(keypair.privateKey);
|
|
142
|
+
console.log("And the public key is:");
|
|
143
|
+
keypair.publicKey = node_forge_1.default.pki.ed25519.publicKeyFromPrivateKey({
|
|
144
|
+
privateKey: keypair.privateKey,
|
|
145
|
+
});
|
|
146
|
+
console.log(keypair.publicKey);
|
|
147
|
+
return keypair;
|
|
148
|
+
}
|
|
149
|
+
static loadFromBufferString(content) {
|
|
150
|
+
let keypair = { publicKey: null, privateKey: null };
|
|
151
|
+
keypair.privateKey = Buffer.from(JSON.parse(content));
|
|
152
|
+
keypair.publicKey = node_forge_1.default.pki.ed25519.publicKeyFromPrivateKey({
|
|
153
|
+
privateKey: keypair.privateKey,
|
|
154
|
+
});
|
|
155
|
+
return keypair;
|
|
156
|
+
}
|
|
157
|
+
static sign(message, privateKey) {
|
|
158
|
+
// REVIEW Test HexToForge support
|
|
159
|
+
if (privateKey.type == "string") {
|
|
160
|
+
console.log("[HexToForge] Deriving a buffer from privateKey...");
|
|
161
|
+
privateKey = (0, dataManipulation_1.HexToForge)(privateKey);
|
|
162
|
+
}
|
|
163
|
+
return node_forge_1.default.pki.ed25519.sign({
|
|
164
|
+
message,
|
|
165
|
+
encoding: "utf8",
|
|
166
|
+
privateKey,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
static verify(signed, signature, publicKey) {
|
|
170
|
+
// REVIEW Test HexToForge support
|
|
171
|
+
if (signature.type == "string") {
|
|
172
|
+
console.log("[HexToForge] Deriving a buffer from signature...");
|
|
173
|
+
signature = (0, dataManipulation_1.HexToForge)(signature);
|
|
174
|
+
}
|
|
175
|
+
if (publicKey.type == "string") {
|
|
176
|
+
console.log("[HexToForge] Deriving a buffer from publicKey...");
|
|
177
|
+
publicKey = (0, dataManipulation_1.HexToForge)(publicKey);
|
|
178
|
+
}
|
|
179
|
+
// Also, we have to sanitize buffers so that they are forge compatible
|
|
180
|
+
if (signature.type == "Buffer") {
|
|
181
|
+
console.log("[*] Normalizing signature...");
|
|
182
|
+
console.log(typeof signature);
|
|
183
|
+
signature = Buffer.from(signature); // REVIEW Does not work in bun
|
|
184
|
+
}
|
|
185
|
+
if (publicKey.type == "Buffer") {
|
|
186
|
+
console.log("[*] Normalizing publicKey...");
|
|
187
|
+
publicKey = Buffer.from(publicKey); // REVIEW Does not work in bun
|
|
188
|
+
}
|
|
189
|
+
console.log("[*] Verifying the signature of: " + signed + "\n");
|
|
190
|
+
console.log("[*] Using the signature: ");
|
|
191
|
+
console.log(signature);
|
|
192
|
+
console.log("[*] And the public key: ");
|
|
193
|
+
console.log(publicKey);
|
|
194
|
+
return node_forge_1.default.pki.ed25519.verify({
|
|
195
|
+
message: signed,
|
|
196
|
+
encoding: "utf8",
|
|
197
|
+
signature: signature,
|
|
198
|
+
publicKey: publicKey,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
20
201
|
}
|
|
202
|
+
exports.Cryptography = Cryptography;
|
|
21
203
|
Cryptography.ed25519 = {
|
|
22
204
|
sign: (message, privateKey) => {
|
|
23
205
|
// REVIEW Test HexToForge support
|
|
@@ -101,5 +283,4 @@ Cryptography.rsa = {
|
|
|
101
283
|
return [true, decrypted.toString()];
|
|
102
284
|
},
|
|
103
285
|
};
|
|
104
|
-
exports.default = Cryptography;
|
|
105
286
|
//# sourceMappingURL=Cryptography.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cryptography.js","sourceRoot":"","sources":["../../../src/encryption/Cryptography.ts"],"names":[],"mappings":";AAAA;;;;;;;;;EASE
|
|
1
|
+
{"version":3,"file":"Cryptography.js","sourceRoot":"","sources":["../../../src/encryption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,CAAC,SAAS,CAAC,CAAA;QACtC,CAAC;QACD,2CAA2C;QAC3C,IAAI,KAAK,GAAG,oBAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QACxC,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC1C,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;IAC5B,CAAC;IAED,+CAA+C;IAC/C,OAAO,EAAE,CACL,OAAe,EACf,aAA6C,IAAI,EACnC,EAAE;QAChB,mDAAmD;QACnD,IAAI,CAAC;YACD,IAAI,UAAU,CAAC,IAAI,IAAI,QAAQ,EAAE,CAAC;gBAC9B,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAA;gBACvD,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YACxC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,OAAO,CAAC,GAAG,CACP,6EAA6E,CAChF,CAAA;YACD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QAClB,CAAC;QACD,gDAAgD;QAChD,4DAA4D;QAC5D,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CACP,yCAAyC,CAC5C,CAAA;YACD,OAAO,CAAC,KAAK,EAAE,sBAAsB,CAAC,CAAA;QAC1C,CAAC;QACD,IAAI,OAAO,GAAG,oBAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC1C,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC7C,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAA;IACvC,CAAC;CACJ,CAAA"}
|
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.Hashing = void 0;
|
|
16
17
|
const node_forge_1 = __importDefault(require("node-forge"));
|
|
17
18
|
class Hashing {
|
|
18
19
|
static sha256(message) {
|
|
@@ -21,5 +22,5 @@ class Hashing {
|
|
|
21
22
|
return md.digest().toHex();
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
exports.
|
|
25
|
+
exports.Hashing = Hashing;
|
|
25
26
|
//# sourceMappingURL=Hashing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hashing.js","sourceRoot":"","sources":["../../../src/encryption/Hashing.ts"],"names":[],"mappings":";AAAA;;;;;;;;;EASE
|
|
1
|
+
{"version":3,"file":"Hashing.js","sourceRoot":"","sources":["../../../src/encryption/Hashing.ts"],"names":[],"mappings":";AAAA;;;;;;;;;EASE;;;;;;AAEF,4DAA8B;AAE9B,MAAa,OAAO;IAChB,MAAM,CAAC,MAAM,CAAC,OAAe;QACzB,MAAM,EAAE,GAAG,oBAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA;QAChC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAClB,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAA;IAC9B,CAAC;CACJ;AAND,0BAMC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * as FHE from './FHE';
|
|
2
2
|
export * as PQC from './PQC';
|
|
3
3
|
export * as zK from './zK';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export { Cryptography } from './Cryptography';
|
|
5
|
+
export { Hashing } from './Hashing';
|
|
@@ -27,6 +27,8 @@ exports.Hashing = exports.Cryptography = exports.zK = exports.PQC = exports.FHE
|
|
|
27
27
|
exports.FHE = __importStar(require("./FHE"));
|
|
28
28
|
exports.PQC = __importStar(require("./PQC"));
|
|
29
29
|
exports.zK = __importStar(require("./zK"));
|
|
30
|
-
|
|
31
|
-
exports
|
|
30
|
+
var Cryptography_1 = require("./Cryptography");
|
|
31
|
+
Object.defineProperty(exports, "Cryptography", { enumerable: true, get: function () { return Cryptography_1.Cryptography; } });
|
|
32
|
+
var Hashing_1 = require("./Hashing");
|
|
33
|
+
Object.defineProperty(exports, "Hashing", { enumerable: true, get: function () { return Hashing_1.Hashing; } });
|
|
32
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/encryption/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA4B;AAC5B,6CAA4B;AAC5B,2CAA0B;AAC1B,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/encryption/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA4B;AAC5B,6CAA4B;AAC5B,2CAA0B;AAC1B,+CAA6C;AAApC,4GAAA,YAAY,OAAA;AACrB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA"}
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.xmwebsdk = exports.xmlocalsdk = exports.utils = exports.encryption = exports.types = void 0;
|
|
26
|
+
exports.wallet = exports.xmwebsdk = exports.xmlocalsdk = exports.utils = exports.encryption = exports.types = void 0;
|
|
27
27
|
// Common types and constants
|
|
28
28
|
exports.types = __importStar(require("./types"));
|
|
29
29
|
// Basic cryptographic and data manipulation functions
|
|
@@ -32,4 +32,5 @@ exports.utils = __importStar(require("./utils"));
|
|
|
32
32
|
// Specific features of the SDK
|
|
33
33
|
exports.xmlocalsdk = __importStar(require("./multichain/localsdk"));
|
|
34
34
|
exports.xmwebsdk = __importStar(require("./multichain/websdk"));
|
|
35
|
+
exports.wallet = __importStar(require("./wallet"));
|
|
35
36
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA6B;AAC7B,iDAAgC;AAChC,sDAAsD;AACtD,2DAA0C;AAC1C,iDAAgC;AAChC,gCAAgC;AAChC,oEAAmD;AACnD,gEAA+C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA6B;AAC7B,iDAAgC;AAChC,sDAAsD;AACtD,2DAA0C;AAC1C,iDAAgC;AAChC,gCAAgC;AAChC,oEAAmD;AACnD,gEAA+C;AAC/C,mDAAkC"}
|
|
@@ -1,47 +1,34 @@
|
|
|
1
|
-
import { Keypair, Connection,
|
|
1
|
+
import { Keypair, Connection, VersionedTransaction } from "@solana/web3.js";
|
|
2
2
|
import { IPayOptions } from "./types/interfaces";
|
|
3
|
-
import { DefaultChain
|
|
3
|
+
import { DefaultChain } from "./types/defaultChain";
|
|
4
4
|
interface SignTxOptions {
|
|
5
5
|
/**
|
|
6
6
|
* The private key to sign the transaction with, instead of the connected wallet.
|
|
7
7
|
*/
|
|
8
8
|
privateKey?: string;
|
|
9
|
-
/**
|
|
10
|
-
* The address of your nonce account for signing with durable nonces.
|
|
11
|
-
*/
|
|
12
|
-
nonceAccountAddress?: string;
|
|
13
|
-
/**
|
|
14
|
-
* The secret key of the nonce account authority, for signing the tx.
|
|
15
|
-
*
|
|
16
|
-
* Defaults to the connected wallet's secret key.
|
|
17
|
-
*/
|
|
18
|
-
nonceAccountAuthority?: string;
|
|
19
9
|
}
|
|
20
|
-
export declare class SOLANA extends DefaultChain
|
|
10
|
+
export declare class SOLANA extends DefaultChain {
|
|
21
11
|
private static instance;
|
|
22
12
|
wallet: Keypair;
|
|
23
13
|
provider: Connection;
|
|
24
14
|
constructor(rpc_url: string);
|
|
25
15
|
connect(): Promise<boolean>;
|
|
26
16
|
disconnect(): Promise<boolean>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
createWallet(): Promise<{
|
|
18
|
+
address: string;
|
|
19
|
+
secretKey: string;
|
|
20
|
+
keypair: Keypair;
|
|
21
|
+
}>;
|
|
22
|
+
connectWallet(privateKey: string): Promise<Keypair>;
|
|
33
23
|
getBalance(address: string): Promise<string>;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
readNonce(address: string): Promise<NonceAccount>;
|
|
37
|
-
createNonceAccount(): Promise<string>;
|
|
38
|
-
signTransactions(transactions: Transaction[], options?: SignTxOptions): Promise<Transaction[]>;
|
|
24
|
+
signTransaction(tx: VersionedTransaction, options?: SignTxOptions): Promise<Uint8Array>;
|
|
25
|
+
signTransactions(transactions: VersionedTransaction[], options?: SignTxOptions): Promise<Uint8Array[]>;
|
|
39
26
|
getAddress(): string;
|
|
40
|
-
getEmptyTransaction():
|
|
41
|
-
preparePay(receiver: string, amount: string, options?: SignTxOptions): Promise<
|
|
42
|
-
preparePays(payments: IPayOptions[], options?: SignTxOptions): Promise<
|
|
43
|
-
prepareTransfer(receiver: string, amount: string, options
|
|
44
|
-
prepareTransfers(transfers: IPayOptions[], options
|
|
27
|
+
getEmptyTransaction(): VersionedTransaction;
|
|
28
|
+
preparePay(receiver: string, amount: string, options?: SignTxOptions): Promise<Uint8Array>;
|
|
29
|
+
preparePays(payments: IPayOptions[], options?: SignTxOptions): Promise<Uint8Array[]>;
|
|
30
|
+
prepareTransfer(receiver: string, amount: string, options?: SignTxOptions): Promise<Uint8Array>;
|
|
31
|
+
prepareTransfers(transfers: IPayOptions[], options?: SignTxOptions): Promise<Uint8Array[]>;
|
|
45
32
|
static getInstance(): SOLANA | boolean;
|
|
46
33
|
static createInstance(rpc_url: string): SOLANA;
|
|
47
34
|
}
|
|
@@ -14,7 +14,9 @@ class SOLANA extends defaultChain_1.DefaultChain {
|
|
|
14
14
|
this.name = "solana";
|
|
15
15
|
}
|
|
16
16
|
async connect() {
|
|
17
|
-
this.provider = new web3_js_1.Connection(this.rpc_url
|
|
17
|
+
this.provider = new web3_js_1.Connection(this.rpc_url, {
|
|
18
|
+
confirmTransactionInitialTimeout: 5000,
|
|
19
|
+
});
|
|
18
20
|
const version = await this.provider.getVersion();
|
|
19
21
|
this.connected = Number.isInteger(version["feature-set"]);
|
|
20
22
|
return this.connected;
|
|
@@ -23,18 +25,18 @@ class SOLANA extends defaultChain_1.DefaultChain {
|
|
|
23
25
|
this.resetInstance();
|
|
24
26
|
return true;
|
|
25
27
|
}
|
|
26
|
-
|
|
28
|
+
async createWallet() {
|
|
29
|
+
const keypair = web3_js_1.Keypair.generate();
|
|
30
|
+
return {
|
|
31
|
+
address: keypair.publicKey.toBase58(),
|
|
32
|
+
secretKey: bs58_1.default.encode(keypair.secretKey),
|
|
33
|
+
keypair: keypair,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
27
36
|
// ANCHOR Public methods
|
|
28
|
-
async connectWallet(privateKey
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
privateKeyBuffer = bs58_1.default.decode(privateKey);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
const pk = privateKey.split(",").map(x => parseInt(x));
|
|
35
|
-
privateKeyBuffer = Buffer.from(pk);
|
|
36
|
-
}
|
|
37
|
-
this.wallet = web3_js_1.Keypair.fromSecretKey(privateKeyBuffer);
|
|
37
|
+
async connectWallet(privateKey) {
|
|
38
|
+
const pkBuffer = bs58_1.default.decode(privateKey);
|
|
39
|
+
this.wallet = web3_js_1.Keypair.fromSecretKey(pkBuffer);
|
|
38
40
|
return this.wallet;
|
|
39
41
|
}
|
|
40
42
|
async getBalance(address) {
|
|
@@ -42,20 +44,6 @@ class SOLANA extends defaultChain_1.DefaultChain {
|
|
|
42
44
|
const balance = await this.provider.getBalance(publicKey);
|
|
43
45
|
return balance.toString();
|
|
44
46
|
}
|
|
45
|
-
// async pay(to: string, amount: string): Promise<any> {
|
|
46
|
-
// required(this.wallet, 'Wallet not connected')
|
|
47
|
-
// // TODO
|
|
48
|
-
// return null
|
|
49
|
-
// }
|
|
50
|
-
async info() {
|
|
51
|
-
let info = "";
|
|
52
|
-
// TODO
|
|
53
|
-
return info;
|
|
54
|
-
}
|
|
55
|
-
// INFO Returning an empty raw transaction skeleton
|
|
56
|
-
// async createRawTransaction(): Promise<Transaction> {
|
|
57
|
-
// }
|
|
58
|
-
// INFO Placeholder compatibility function that is here only for the interface
|
|
59
47
|
async signTransaction(tx, options) {
|
|
60
48
|
(0, utils_1.required)(this.wallet, "Wallet not connected");
|
|
61
49
|
// LINK https://docs.shyft.to/tutorials/how-to-sign-transactions-on-solana
|
|
@@ -64,110 +52,54 @@ class SOLANA extends defaultChain_1.DefaultChain {
|
|
|
64
52
|
const txs = await this.signTransactions([tx], options);
|
|
65
53
|
return txs[0];
|
|
66
54
|
}
|
|
67
|
-
async readNonce(address) {
|
|
68
|
-
console.log("reading nonce account: ", address);
|
|
69
|
-
const pubkey = new web3_js_1.PublicKey(address);
|
|
70
|
-
const accountInfo = await this.provider.getAccountInfo(pubkey);
|
|
71
|
-
console.log("accountInfo: ", accountInfo);
|
|
72
|
-
if (accountInfo) {
|
|
73
|
-
return web3_js_1.NonceAccount.fromAccountData(accountInfo?.data);
|
|
74
|
-
}
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
async createNonceAccount() {
|
|
78
|
-
(0, utils_1.required)(this.wallet, "Wallet not connected");
|
|
79
|
-
let tx = new web3_js_1.Transaction();
|
|
80
|
-
const nonceAccount = web3_js_1.Keypair.generate();
|
|
81
|
-
const create_acc_ix = web3_js_1.SystemProgram.createAccount({
|
|
82
|
-
fromPubkey: this.wallet.publicKey,
|
|
83
|
-
newAccountPubkey: nonceAccount.publicKey,
|
|
84
|
-
lamports: await this.provider.getMinimumBalanceForRentExemption(web3_js_1.NONCE_ACCOUNT_LENGTH),
|
|
85
|
-
space: web3_js_1.NONCE_ACCOUNT_LENGTH,
|
|
86
|
-
programId: web3_js_1.SystemProgram.programId,
|
|
87
|
-
});
|
|
88
|
-
const init_nonce_ix = web3_js_1.SystemProgram.nonceInitialize({
|
|
89
|
-
noncePubkey: nonceAccount.publicKey,
|
|
90
|
-
authorizedPubkey: this.wallet.publicKey,
|
|
91
|
-
});
|
|
92
|
-
tx.add(create_acc_ix, init_nonce_ix);
|
|
93
|
-
const txhash = this.provider.sendTransaction(tx, [
|
|
94
|
-
this.wallet,
|
|
95
|
-
nonceAccount,
|
|
96
|
-
]);
|
|
97
|
-
console.log("txhash: ", txhash);
|
|
98
|
-
return nonceAccount.publicKey.toBase58();
|
|
99
|
-
}
|
|
100
55
|
async signTransactions(transactions, options) {
|
|
101
|
-
(0, utils_1.required)(this.wallet, "Wallet not connected");
|
|
102
|
-
let
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (nonceAccAvailable && options.nonceAccountAuthority) {
|
|
108
|
-
nonceAuthority = web3_js_1.Keypair.fromSecretKey(bs58_1.default.decode(options.nonceAccountAuthority));
|
|
109
|
-
}
|
|
110
|
-
// if we have the nonce address, create a nonce advance instruction
|
|
111
|
-
if (nonceAccAvailable) {
|
|
112
|
-
advanceNonceIx = web3_js_1.SystemProgram.nonceAdvance({
|
|
113
|
-
authorizedPubkey: nonceAuthority.publicKey,
|
|
114
|
-
noncePubkey: new web3_js_1.PublicKey(options.nonceAccountAddress),
|
|
115
|
-
});
|
|
116
|
-
nonceAccount = await this.readNonce(options.nonceAccountAddress);
|
|
117
|
-
}
|
|
118
|
-
// if advance instruction is not null
|
|
119
|
-
// ie. we have the nonce address,
|
|
120
|
-
// insert the advance nonce ix at instructions index 0
|
|
121
|
-
// on each transaction
|
|
122
|
-
if (advanceNonceIx && nonceAccount) {
|
|
123
|
-
transactions.forEach(tx => {
|
|
124
|
-
tx.instructions.splice(0, 0, advanceNonceIx);
|
|
125
|
-
// update recent block hash to use the current nonce
|
|
126
|
-
tx.recentBlockhash = nonceAccount.nonce;
|
|
127
|
-
nonceAccount?.nonce;
|
|
128
|
-
// TODO: FIND OUT WHAT HAPPENS WHEN MULTIPLE TX HAVE THE SAME DURABLE NONCE
|
|
129
|
-
});
|
|
56
|
+
(0, utils_1.required)(this.wallet || (options && options.privateKey), "Wallet not connected");
|
|
57
|
+
let signers = [this.wallet];
|
|
58
|
+
if (options && options.privateKey) {
|
|
59
|
+
const privateKeyBuffer = bs58_1.default.decode(options.privateKey);
|
|
60
|
+
const keypair = web3_js_1.Keypair.fromSecretKey(privateKeyBuffer);
|
|
61
|
+
signers = [keypair];
|
|
130
62
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
transactions.forEach(async (tx) => {
|
|
135
|
-
tx.sign(...signers);
|
|
63
|
+
return transactions.map(tx => {
|
|
64
|
+
tx.sign(signers);
|
|
65
|
+
return tx.serialize();
|
|
136
66
|
});
|
|
137
|
-
return transactions;
|
|
138
67
|
}
|
|
139
68
|
getAddress() {
|
|
140
69
|
(0, utils_1.required)(this.wallet, "Wallet not connected");
|
|
141
70
|
return this.wallet.publicKey.toBase58();
|
|
142
71
|
}
|
|
143
72
|
getEmptyTransaction() {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
// empty_tx.lastValidBlockHeight = recentBlockhash.lastValidBlockHeight
|
|
151
|
-
return empty_tx;
|
|
73
|
+
const vmsg = new web3_js_1.TransactionMessage({
|
|
74
|
+
payerKey: this.wallet.publicKey,
|
|
75
|
+
recentBlockhash: "",
|
|
76
|
+
instructions: [],
|
|
77
|
+
}).compileToV0Message();
|
|
78
|
+
return new web3_js_1.VersionedTransaction(vmsg);
|
|
152
79
|
}
|
|
153
80
|
async preparePay(receiver, amount, options) {
|
|
154
81
|
const tx = await this.preparePays([{ address: receiver, amount }], options);
|
|
155
82
|
return tx[0];
|
|
156
83
|
}
|
|
157
84
|
async preparePays(payments, options) {
|
|
158
|
-
const
|
|
85
|
+
const blockInfo = await this.provider.getLatestBlockhash();
|
|
159
86
|
const transactions = payments.map(payment => {
|
|
160
|
-
|
|
161
|
-
tx.recentBlockhash = recentBlockhash.blockhash;
|
|
162
|
-
tx.lastValidBlockHeight = recentBlockhash.lastValidBlockHeight;
|
|
87
|
+
// create a transfer instruction
|
|
163
88
|
const transferIx = web3_js_1.SystemProgram.transfer({
|
|
164
89
|
fromPubkey: this.wallet.publicKey,
|
|
165
90
|
toPubkey: new web3_js_1.PublicKey(payment.address),
|
|
166
91
|
lamports: parseFloat(payment.amount) * web3_js_1.LAMPORTS_PER_SOL,
|
|
167
92
|
});
|
|
168
|
-
|
|
169
|
-
|
|
93
|
+
// compile the instruction into a message
|
|
94
|
+
const vmsg = new web3_js_1.TransactionMessage({
|
|
95
|
+
instructions: [transferIx],
|
|
96
|
+
payerKey: this.wallet.publicKey,
|
|
97
|
+
recentBlockhash: blockInfo.blockhash,
|
|
98
|
+
}).compileToV0Message();
|
|
99
|
+
// create a versioned transaction
|
|
100
|
+
return new web3_js_1.VersionedTransaction(vmsg);
|
|
170
101
|
});
|
|
102
|
+
// sign the transactions
|
|
171
103
|
return this.signTransactions(transactions, options);
|
|
172
104
|
}
|
|
173
105
|
async prepareTransfer(receiver, amount, options) {
|
|
@@ -176,24 +108,6 @@ class SOLANA extends defaultChain_1.DefaultChain {
|
|
|
176
108
|
async prepareTransfers(transfers, options) {
|
|
177
109
|
return await this.preparePays(transfers, options);
|
|
178
110
|
}
|
|
179
|
-
// TODO: move sendTransaction to localsdk
|
|
180
|
-
// INFO Sending a transfer transaction on Solana network
|
|
181
|
-
// sendTransaction({ to, amount }) {
|
|
182
|
-
// required(this.wallet, 'Wallet not connected')
|
|
183
|
-
// let tx = new Transaction()
|
|
184
|
-
// tx.add(
|
|
185
|
-
// SystemProgram.transfer({
|
|
186
|
-
// fromPubkey: this.wallet.publicKey,
|
|
187
|
-
// toPubkey: to,
|
|
188
|
-
// lamports: amount * LAMPORTS_PER_SOL,
|
|
189
|
-
// })
|
|
190
|
-
// )
|
|
191
|
-
// let result = sendAndConfirmTransaction(this.provider, tx, [
|
|
192
|
-
// this.wallet,
|
|
193
|
-
// ])
|
|
194
|
-
// return result
|
|
195
|
-
// }
|
|
196
|
-
// ANCHOR Static singleton methods
|
|
197
111
|
static getInstance() {
|
|
198
112
|
if (!SOLANA.instance) {
|
|
199
113
|
return false;
|