@kynesyslabs/demosdk 1.0.13 → 1.0.15
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/README.md +1 -10
- package/build/multichain/core/index.d.ts +1 -1
- package/build/multichain/core/solana.d.ts +19 -0
- package/build/multichain/core/solana.js +119 -0
- package/build/multichain/core/solana.js.map +1 -0
- package/build/multichain/core/types/defaultChain.d.ts +2 -2
- package/build/multichain/core/types/defaultChain.js.map +1 -1
- package/build/multichain/core/types/interfaces.d.ts +1 -1
- package/build/multichain/localsdk/evm.d.ts +2 -5
- package/build/multichain/localsdk/evm.js.map +1 -1
- package/build/multichain/localsdk/ibc.d.ts +2 -5
- package/build/multichain/localsdk/ibc.js.map +1 -1
- package/build/multichain/localsdk/multiversx.d.ts +2 -5
- package/build/multichain/localsdk/multiversx.js.map +1 -1
- package/build/multichain/localsdk/xrp.d.ts +2 -15
- package/build/multichain/localsdk/xrp.js.map +1 -1
- package/build/types/blockchain/Transaction.d.ts +2 -2
- package/build/types/web2/index.d.ts +8 -1
- package/build/types/web2/index.js +9 -0
- package/build/types/web2/index.js.map +1 -1
- package/build/websdk/DemosTransactions.d.ts +8 -0
- package/build/websdk/DemosTransactions.js +100 -0
- package/build/websdk/DemosTransactions.js.map +1 -0
- package/build/websdk/DemosWebAuth.d.ts +27 -0
- package/build/websdk/DemosWebAuth.js +200 -0
- package/build/websdk/DemosWebAuth.js.map +1 -0
- package/build/websdk/Web2Transactions.d.ts +2 -0
- package/build/websdk/Web2Transactions.js +58 -0
- package/build/websdk/Web2Transactions.js.map +1 -0
- package/build/websdk/XMTransactions.d.ts +69 -0
- package/build/websdk/XMTransactions.js +124 -0
- package/build/websdk/XMTransactions.js.map +1 -0
- package/build/websdk/demos.d.ts +61 -0
- package/build/websdk/demos.js +401 -0
- package/build/websdk/demos.js.map +1 -0
- package/build/websdk/index.d.ts +11 -0
- package/build/websdk/index.js +52 -0
- package/build/websdk/index.js.map +1 -0
- package/build/websdk/rsa.d.ts +19 -0
- package/build/websdk/rsa.js +86 -0
- package/build/websdk/rsa.js.map +1 -0
- package/build/websdk/types/IBuffer.d.ts +4 -0
- package/build/websdk/types/IBuffer.js +3 -0
- package/build/websdk/types/IBuffer.js.map +1 -0
- package/build/websdk/types/KeyPair.d.ts +9 -0
- package/build/websdk/types/KeyPair.js +3 -0
- package/build/websdk/types/KeyPair.js.map +1 -0
- package/build/websdk/utils/bufferizer.d.ts +9 -0
- package/build/websdk/utils/bufferizer.js +19 -0
- package/build/websdk/utils/bufferizer.js.map +1 -0
- package/build/websdk/utils/forge_converter.d.ts +3 -0
- package/build/websdk/utils/forge_converter.js +73 -0
- package/build/websdk/utils/forge_converter.js.map +1 -0
- package/build/websdk/utils/required.d.ts +21 -0
- package/build/websdk/utils/required.js +48 -0
- package/build/websdk/utils/required.js.map +1 -0
- package/build/websdk/utils/sha256.d.ts +4 -0
- package/build/websdk/utils/sha256.js +18 -0
- package/build/websdk/utils/sha256.js.map +1 -0
- package/build/websdk/utils/skeletons.d.ts +37 -0
- package/build/websdk/utils/skeletons.js +70 -0
- package/build/websdk/utils/skeletons.js.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.DemosWebAuth = void 0;
|
|
30
|
+
/* eslint-disable no-unused-vars */
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
const node_forge_1 = __importDefault(require("node-forge"));
|
|
33
|
+
const required_1 = require("./utils/required");
|
|
34
|
+
const forge_converter = __importStar(require("./utils/forge_converter"));
|
|
35
|
+
const rsa_1 = require("./rsa");
|
|
36
|
+
// TODO Could this be an universal "Sign in with DEMOS" ? Maybe
|
|
37
|
+
// INFO Enabling DEMOS wallet connections in the browser exposing a singleton
|
|
38
|
+
// NOTE All the methods below return an array of [boolean, string | any] where any can be the result of the method
|
|
39
|
+
class DemosWebAuth {
|
|
40
|
+
constructor() {
|
|
41
|
+
this.loggedIn = false;
|
|
42
|
+
this.keypair = null;
|
|
43
|
+
this.stringified_keypair = null;
|
|
44
|
+
this.loggedIn = false;
|
|
45
|
+
this.keypair = null;
|
|
46
|
+
this.stringified_keypair = null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Description placeholder
|
|
50
|
+
* @date 14/9/2023 - 13:52:34
|
|
51
|
+
*
|
|
52
|
+
* @static
|
|
53
|
+
* @returns {DemosWebAuth}
|
|
54
|
+
*/
|
|
55
|
+
static getInstance() {
|
|
56
|
+
if (!this._instance) {
|
|
57
|
+
this._instance = new DemosWebAuth();
|
|
58
|
+
}
|
|
59
|
+
return this._instance;
|
|
60
|
+
}
|
|
61
|
+
async create(seed = "") {
|
|
62
|
+
if (!seed) {
|
|
63
|
+
seed = node_forge_1.default.random.getBytesSync(32);
|
|
64
|
+
}
|
|
65
|
+
console.log('[CREATE WALLET] Creating wallet...');
|
|
66
|
+
console.log('[CREATE WALLET] Seed: ' + seed);
|
|
67
|
+
let result = [true, {}];
|
|
68
|
+
try {
|
|
69
|
+
this.keypair = {
|
|
70
|
+
privateKey: null,
|
|
71
|
+
publicKey: null
|
|
72
|
+
};
|
|
73
|
+
this.keypair = node_forge_1.default.pki.ed25519.generateKeyPair({ seed });
|
|
74
|
+
console.log(this.keypair);
|
|
75
|
+
this.loggedIn = true;
|
|
76
|
+
console.log('[CREATE WALLET] Keypair created!');
|
|
77
|
+
// Stringify the keypair
|
|
78
|
+
console.log('[CREATE WALLET] Stringifying keypair...');
|
|
79
|
+
this.stringified_keypair = {
|
|
80
|
+
privateKey: forge_converter.forgeToString(this.keypair.privateKey),
|
|
81
|
+
publicKey: forge_converter.forgeToString(this.keypair.publicKey)
|
|
82
|
+
};
|
|
83
|
+
result = [true, this.stringified_keypair];
|
|
84
|
+
console.log(this.stringified_keypair);
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
// @ts-expect-error
|
|
88
|
+
result = [false, '[CREATE WALLET ERROR] ' + e.message];
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
// NOTE We just have to accept valid private keys and derive the public key from them
|
|
93
|
+
async login(privKey) {
|
|
94
|
+
if (typeof privKey === 'string') {
|
|
95
|
+
console.log('[LOGIN] Converting private key from string...');
|
|
96
|
+
privKey = forge_converter.stringToForge(privKey);
|
|
97
|
+
if (!privKey) {
|
|
98
|
+
return [false, 'Cannot convert private key from that string!'];
|
|
99
|
+
}
|
|
100
|
+
console.log(privKey);
|
|
101
|
+
console.log('[LOGIN] Private key converted!');
|
|
102
|
+
}
|
|
103
|
+
console.log('[LOGIN WALLET] Logging in...');
|
|
104
|
+
if (!(0, required_1.required)(privKey, false)) {
|
|
105
|
+
return [false, 'You need to provide a private key!'];
|
|
106
|
+
}
|
|
107
|
+
// Serializing the private key as a string
|
|
108
|
+
// console.log("[LOGIN WALLET] Serializing private key...")
|
|
109
|
+
// this.keypair.privateKey = forge_converter.stringToForge(this.stringified_keypair.privateKey)
|
|
110
|
+
// console.log(this.keypair.privateKey)
|
|
111
|
+
this.keypair = {
|
|
112
|
+
privateKey: privKey,
|
|
113
|
+
publicKey: null
|
|
114
|
+
};
|
|
115
|
+
// Logging in avoiding crashes on wrong private keys
|
|
116
|
+
try {
|
|
117
|
+
console.log('[LOGIN WALLET] Deriving public key from private key...');
|
|
118
|
+
this.keypair.publicKey = node_forge_1.default.pki.ed25519.publicKeyFromPrivateKey({ privateKey: privKey });
|
|
119
|
+
this.stringified_keypair = {
|
|
120
|
+
privateKey: forge_converter.forgeToString(this.keypair.privateKey),
|
|
121
|
+
publicKey: forge_converter.forgeToString(this.keypair.publicKey)
|
|
122
|
+
};
|
|
123
|
+
this.loggedIn = true;
|
|
124
|
+
return [true, 'Successfully logged in!'];
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
console.log(e);
|
|
128
|
+
return [false, '[LOGIN ERROR] Cannot derive publicKey!'];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @description Disconnects a wallet from the Demos chain
|
|
133
|
+
* @returns {Promise<[boolean, string]>}
|
|
134
|
+
**/
|
|
135
|
+
async logout() {
|
|
136
|
+
if (!(0, required_1.required)(this.keypair, false)) {
|
|
137
|
+
return [true, 'You are already logged out!'];
|
|
138
|
+
}
|
|
139
|
+
this.loggedIn = false;
|
|
140
|
+
this.keypair = null;
|
|
141
|
+
this.stringified_keypair = null;
|
|
142
|
+
return [true, 'Successfully logged out!'];
|
|
143
|
+
}
|
|
144
|
+
async sign(message) {
|
|
145
|
+
if (!(0, required_1.required)(this.keypair || this.stringified_keypair, false)) {
|
|
146
|
+
return [false, 'You need to login first!'];
|
|
147
|
+
}
|
|
148
|
+
// If needed, we derive the keys from the strings
|
|
149
|
+
if (!this.keypair) {
|
|
150
|
+
console.log('[SIGN WALLET] Deriving buffer keys from strings...');
|
|
151
|
+
this.keypair = {
|
|
152
|
+
privateKey: forge_converter.stringToForge(this.stringified_keypair?.privateKey),
|
|
153
|
+
publicKey: forge_converter.stringToForge(this.stringified_keypair?.publicKey)
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
let result = [true, {}];
|
|
157
|
+
try {
|
|
158
|
+
const sign_result = node_forge_1.default.pki.ed25519.sign({
|
|
159
|
+
message: message,
|
|
160
|
+
privateKey: this.keypair.privateKey
|
|
161
|
+
});
|
|
162
|
+
result = [true, sign_result];
|
|
163
|
+
}
|
|
164
|
+
catch (e) {
|
|
165
|
+
result = [false, '[SIGN ERROR] ' + e.message];
|
|
166
|
+
}
|
|
167
|
+
return result; // Is already a [boolean, string]
|
|
168
|
+
}
|
|
169
|
+
async verify(message, s_signature, s_publicKey) {
|
|
170
|
+
let result = [true, ''];
|
|
171
|
+
// Deriving the buffers from the strings
|
|
172
|
+
const publicKey = forge_converter.stringToForge(s_publicKey);
|
|
173
|
+
const signature = forge_converter.stringToForge(s_signature);
|
|
174
|
+
if (!signature) {
|
|
175
|
+
return [false, 'Invalid signature'];
|
|
176
|
+
}
|
|
177
|
+
if (!publicKey) {
|
|
178
|
+
return [false, 'Invalid public key'];
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
const verify_result = node_forge_1.default.pki.ed25519.verify({
|
|
182
|
+
message: message,
|
|
183
|
+
signature: signature,
|
|
184
|
+
publicKey: publicKey
|
|
185
|
+
});
|
|
186
|
+
result = [true, verify_result];
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
result = [false, '[VERIFY ERROR] ' + e.message];
|
|
190
|
+
}
|
|
191
|
+
return result; // Is already a [boolean, string]
|
|
192
|
+
}
|
|
193
|
+
rsa() {
|
|
194
|
+
return rsa_1.RSA.getInstance();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.DemosWebAuth = DemosWebAuth;
|
|
198
|
+
DemosWebAuth._instance = null;
|
|
199
|
+
// export default DemosWebAuth;
|
|
200
|
+
//# sourceMappingURL=DemosWebAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DemosWebAuth.js","sourceRoot":"","sources":["../../../src/websdk/DemosWebAuth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAmC;AACnC,aAAa;AACb,4DAA+B;AAC/B,+CAA4C;AAC5C,yEAA2D;AAC3D,+BAA4B;AAG5B,+DAA+D;AAE/D,6EAA6E;AAC7E,kHAAkH;AAClH,MAAa,YAAY;IAMxB;QAJA,aAAQ,GAAG,KAAK,CAAC;QACjB,YAAO,GAAoB,IAAI,CAAC;QAChC,wBAAmB,GAA+B,IAAI,CAAC;QAGtD,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,WAAW;QACjB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACrB,IAAI,CAAC,SAAS,GAAG,IAAI,YAAY,EAAE,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,EAAE;QACrB,IAAI,CAAC,IAAI,EAAE,CAAC;YACX,IAAI,GAAG,oBAAK,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACtC,CAAC;QACD,OAA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1KF,oCA2KC;AA1KO,sBAAS,GAAwB,IAAI,AAA5B,CAA6B;AA4K9C,+BAA+B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// INFO This module exposes methods to quickly send Web2 requests to the network
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.prepareWeb2Payload = void 0;
|
|
28
|
+
const skeletons = __importStar(require("./utils/skeletons"));
|
|
29
|
+
// import demos from '../demos'
|
|
30
|
+
const DemosTransactions_1 = require("./DemosTransactions");
|
|
31
|
+
// INFO Web2 Endpoints
|
|
32
|
+
async function prepareWeb2Payload(action = 'GET', url = 'https://icanhazip.com', parameters = [], requestedParameters = null, headers = null, minAttestations = 2) {
|
|
33
|
+
// Generating an empty one and filling it
|
|
34
|
+
const web2_payload = skeletons.web2_request;
|
|
35
|
+
web2_payload.raw.action = action;
|
|
36
|
+
web2_payload.raw.url = url;
|
|
37
|
+
web2_payload.raw.parameters = parameters;
|
|
38
|
+
web2_payload.raw.headers = headers;
|
|
39
|
+
web2_payload.raw.minAttestations = minAttestations;
|
|
40
|
+
// Ensuring content is a known property
|
|
41
|
+
web2_payload.attestations = new Map();
|
|
42
|
+
web2_payload.hash = '';
|
|
43
|
+
web2_payload.signature = '';
|
|
44
|
+
web2_payload.result = '';
|
|
45
|
+
console.log('[Web2Transactions] Payload:');
|
|
46
|
+
console.log(web2_payload);
|
|
47
|
+
// REVIEW Finish upgrading to the new transaction system
|
|
48
|
+
// Creating a web2 payload
|
|
49
|
+
let web2_tx = DemosTransactions_1.DemosTransactions.empty();
|
|
50
|
+
web2_tx.content.type = "web2Request";
|
|
51
|
+
web2_tx.content.data = ["web2Request", web2_payload];
|
|
52
|
+
// Signing the transaction
|
|
53
|
+
web2_tx = await DemosTransactions_1.DemosTransactions.sign(web2_tx);
|
|
54
|
+
// Returning the transaction
|
|
55
|
+
return web2_tx;
|
|
56
|
+
}
|
|
57
|
+
exports.prepareWeb2Payload = prepareWeb2Payload;
|
|
58
|
+
//# sourceMappingURL=Web2Transactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Web2Transactions.js","sourceRoot":"","sources":["../../../src/websdk/Web2Transactions.ts"],"names":[],"mappings":";AAAA,gFAAgF;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhF,6DAA8C;AAC9C,+BAA+B;AAC/B,2DAAwD;AAGxD,sBAAsB;AACf,KAAK,UAAU,kBAAkB,CACtC,MAAM,GAAG,KAAK,EACd,GAAG,GAAG,uBAAuB,EAC7B,UAAU,GAAG,EAAE,EACf,mBAAmB,GAAG,IAAI,EAC1B,OAAO,GAAG,IAAI,EACd,eAAe,GAAG,CAAC;IAEnB,yCAAyC;IACzC,MAAM,YAAY,GAAgB,SAAS,CAAC,YAAY,CAAA;IACxD,YAAY,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAA;IAChC,YAAY,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAA;IAC1B,YAAY,CAAC,GAAG,CAAC,UAAU,GAAG,UAAU,CAAA;IACxC,YAAY,CAAC,GAAG,CAAC,OAAO,GAAG,OAAO,CAAA;IAClC,YAAY,CAAC,GAAG,CAAC,eAAe,GAAG,eAAe,CAAA;IAClD,uCAAuC;IACvC,YAAY,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAA;IACrC,YAAY,CAAC,IAAI,GAAG,EAAE,CAAA;IACtB,YAAY,CAAC,SAAS,GAAG,EAAE,CAAA;IAC3B,YAAY,CAAC,MAAM,GAAG,EAAE,CAAA;IAExB,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;IAC1C,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IACzB,wDAAwD;IACxD,0BAA0B;IAC1B,IAAI,OAAO,GAAgB,qCAAiB,CAAC,KAAK,EAAE,CAAA;IACpD,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,aAAa,CAAA;IACpC,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,CAAA;IACpD,0BAA0B;IAC1B,OAAO,GAAG,MAAM,qCAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC/C,4BAA4B;IAC5B,OAAO,OAAO,CAAA;AAChB,CAAC;AAhCD,gDAgCC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Transaction, XMScript } from "../types";
|
|
2
|
+
declare const XMTransactions: {
|
|
3
|
+
schemas: {
|
|
4
|
+
base_operation: {
|
|
5
|
+
chain: string;
|
|
6
|
+
subchain: string;
|
|
7
|
+
is_evm: boolean;
|
|
8
|
+
rpc: string;
|
|
9
|
+
conditional: boolean;
|
|
10
|
+
task: {
|
|
11
|
+
type: string;
|
|
12
|
+
params: {};
|
|
13
|
+
signedPayloads: any[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
condition_operation: {
|
|
17
|
+
operator: string;
|
|
18
|
+
statement: string;
|
|
19
|
+
callback: string;
|
|
20
|
+
alternative: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
data: {
|
|
24
|
+
loaded_operations: {
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
};
|
|
27
|
+
operations_index: (string | number)[];
|
|
28
|
+
};
|
|
29
|
+
task: {};
|
|
30
|
+
operation: {
|
|
31
|
+
create: (name: string | number, chain: string, subchain: string, is_evm: boolean, rpc: string, task: {
|
|
32
|
+
type: string;
|
|
33
|
+
params: {};
|
|
34
|
+
signedPayloads: any[];
|
|
35
|
+
}, conditional?: boolean) => {
|
|
36
|
+
chain: string;
|
|
37
|
+
subchain: string;
|
|
38
|
+
is_evm: boolean;
|
|
39
|
+
rpc: string;
|
|
40
|
+
conditional: boolean;
|
|
41
|
+
task: {
|
|
42
|
+
type: string;
|
|
43
|
+
params: {};
|
|
44
|
+
signedPayloads: any[];
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
create_condition: (name: string | number, operator: string, statement: string, callback: string, alternative: string) => {
|
|
48
|
+
operator: string;
|
|
49
|
+
statement: string;
|
|
50
|
+
callback: string;
|
|
51
|
+
alternative: string;
|
|
52
|
+
};
|
|
53
|
+
push_signed_payload: (name: string | number, signed_payload: any) => void;
|
|
54
|
+
delete: (name: string | number) => void;
|
|
55
|
+
clear: () => void;
|
|
56
|
+
reorder: (name: any, index: number) => void;
|
|
57
|
+
update: (name: string | number, chain: string, subchain: string, is_evm: boolean, rpc: string, task: {
|
|
58
|
+
type: string;
|
|
59
|
+
params: {};
|
|
60
|
+
}, conditional: boolean) => void;
|
|
61
|
+
get: () => {
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
};
|
|
64
|
+
get_by_name: (name: string | number) => any;
|
|
65
|
+
get_ordered_index: () => (string | number)[];
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
declare function prepareXMPayload(xm_payload: XMScript): Promise<Transaction>;
|
|
69
|
+
export { XMTransactions, prepareXMPayload };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// INFO Use the src/features/multichain/chainscript/chainscript.chs for the specs
|
|
3
|
+
// NOTE This module is meant to be used with the demos websdk
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.prepareXMPayload = exports.XMTransactions = void 0;
|
|
6
|
+
const DemosTransactions_1 = require("./DemosTransactions");
|
|
7
|
+
// INFO Using the methods below to create, manage and send chainscript-like scripts
|
|
8
|
+
const XMTransactions = {
|
|
9
|
+
schemas: {
|
|
10
|
+
base_operation: {
|
|
11
|
+
chain: '',
|
|
12
|
+
subchain: '',
|
|
13
|
+
is_evm: false,
|
|
14
|
+
rpc: '',
|
|
15
|
+
conditional: false,
|
|
16
|
+
task: {
|
|
17
|
+
type: '',
|
|
18
|
+
params: {},
|
|
19
|
+
signedPayloads: []
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
condition_operation: {
|
|
23
|
+
operator: '',
|
|
24
|
+
statement: '',
|
|
25
|
+
callback: '',
|
|
26
|
+
alternative: ''
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
data: {
|
|
30
|
+
// NOTE This is a list of all operations that have been loaded in the current session
|
|
31
|
+
loaded_operations: {},
|
|
32
|
+
operations_index: []
|
|
33
|
+
},
|
|
34
|
+
task: {},
|
|
35
|
+
operation: {
|
|
36
|
+
// ANCHOR Setters
|
|
37
|
+
// NOTE Creating and adding a new operation to the current session list
|
|
38
|
+
// megabudino was here: I added the conditional parameter; changed operation.task = task to not overwrite
|
|
39
|
+
create: function (name, chain, subchain, is_evm, rpc, task, conditional = false) {
|
|
40
|
+
// TODO Bugfix: implement a name
|
|
41
|
+
const operation = { ...XMTransactions.schemas.base_operation };
|
|
42
|
+
operation.chain = chain;
|
|
43
|
+
operation.subchain = subchain;
|
|
44
|
+
operation.is_evm = is_evm;
|
|
45
|
+
operation.rpc = rpc;
|
|
46
|
+
operation.conditional = conditional;
|
|
47
|
+
operation.task = task;
|
|
48
|
+
XMTransactions.data.loaded_operations[name] = operation;
|
|
49
|
+
XMTransactions.data.operations_index.push(name);
|
|
50
|
+
return operation;
|
|
51
|
+
},
|
|
52
|
+
// megabudino was here: this is the function that creates the condition operation
|
|
53
|
+
create_condition: function (name, operator, statement, callback, alternative) {
|
|
54
|
+
const condition = { ...XMTransactions.schemas.condition_operation };
|
|
55
|
+
condition.operator = operator;
|
|
56
|
+
condition.statement = statement;
|
|
57
|
+
condition.callback = callback;
|
|
58
|
+
condition.alternative = alternative;
|
|
59
|
+
XMTransactions.data.loaded_operations[name] = condition;
|
|
60
|
+
XMTransactions.data.operations_index.push(name);
|
|
61
|
+
return condition;
|
|
62
|
+
},
|
|
63
|
+
// megabudino was here: this is the function to push signed payloads to the task
|
|
64
|
+
push_signed_payload: function (name, signed_payload) {
|
|
65
|
+
XMTransactions.data.loaded_operations[name].task.signedPayloads.push(signed_payload);
|
|
66
|
+
},
|
|
67
|
+
// NOTE Deleting an operation from the current session list
|
|
68
|
+
delete: function (name) {
|
|
69
|
+
delete XMTransactions.data.loaded_operations[name];
|
|
70
|
+
const index = XMTransactions.data.operations_index.indexOf(name);
|
|
71
|
+
XMTransactions.data.operations_index.splice(index, 1);
|
|
72
|
+
},
|
|
73
|
+
clear: function () {
|
|
74
|
+
XMTransactions.data.loaded_operations = {};
|
|
75
|
+
XMTransactions.data.operations_index = [];
|
|
76
|
+
},
|
|
77
|
+
// NOTE Changing operation order for an operation from the current session list
|
|
78
|
+
reorder: function (name, index) {
|
|
79
|
+
// FIXME Security: check boundaries to avoid circling
|
|
80
|
+
const operation_current = XMTransactions.data.operations_index.indexOf(name);
|
|
81
|
+
// Deleting and...
|
|
82
|
+
XMTransactions.data.operations_index.splice(operation_current, 1);
|
|
83
|
+
// ...inserting it at the new index
|
|
84
|
+
XMTransactions.data.operations_index.splice(index, 0, name);
|
|
85
|
+
},
|
|
86
|
+
// NOTE Updating an operation from the current session list
|
|
87
|
+
// megabudino was here: I added the conditional parameter; changed operation.task = task to not overwrite
|
|
88
|
+
update: function (name, chain, subchain, is_evm, rpc, task, conditional) {
|
|
89
|
+
const operation = { ...XMTransactions.schemas.base_operation };
|
|
90
|
+
operation.chain = chain;
|
|
91
|
+
operation.subchain = subchain;
|
|
92
|
+
operation.is_evm = is_evm;
|
|
93
|
+
operation.rpc = rpc;
|
|
94
|
+
operation.task.type = task.type;
|
|
95
|
+
operation.task.params = task.params;
|
|
96
|
+
operation.conditional = conditional;
|
|
97
|
+
XMTransactions.data.loaded_operations[name] = operation;
|
|
98
|
+
},
|
|
99
|
+
// ANCHOR Getters
|
|
100
|
+
// NOTE Getting all the operations from the current session list
|
|
101
|
+
get: function () {
|
|
102
|
+
return XMTransactions.data.loaded_operations;
|
|
103
|
+
},
|
|
104
|
+
// NOTE Getting an operation from the current session list by name
|
|
105
|
+
get_by_name: function (name) {
|
|
106
|
+
return XMTransactions.data.loaded_operations[name];
|
|
107
|
+
},
|
|
108
|
+
get_ordered_index: function () {
|
|
109
|
+
return XMTransactions.data.operations_index;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
exports.XMTransactions = XMTransactions;
|
|
114
|
+
async function prepareXMPayload(xm_payload) {
|
|
115
|
+
var xm_transaction = DemosTransactions_1.DemosTransactions.empty();
|
|
116
|
+
xm_transaction.content.type = "crosschainOperation";
|
|
117
|
+
xm_transaction.content.data = ["crosschainOperation", xm_payload];
|
|
118
|
+
// Signing the transaction
|
|
119
|
+
xm_transaction = await DemosTransactions_1.DemosTransactions.sign(xm_transaction);
|
|
120
|
+
// Returning the transaction
|
|
121
|
+
return xm_transaction;
|
|
122
|
+
}
|
|
123
|
+
exports.prepareXMPayload = prepareXMPayload;
|
|
124
|
+
//# sourceMappingURL=XMTransactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XMTransactions.js","sourceRoot":"","sources":["../../../src/websdk/XMTransactions.ts"],"names":[],"mappings":";AAAA,iFAAiF;AACjF,6DAA6D;;;AAG7D,2DAAwD;AAExD,mFAAmF;AACnF,MAAM,cAAc,GAAG;IACrB,OAAO,EAAE;QACP,cAAc,EAAE;YACd,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,EAAE;YACP,WAAW,EAAE,KAAK;YAClB,IAAI,EAAE;gBACJ,IAAI,EAAE,EAAE;gBACR,MAAM,EAAE,EAAE;gBACV,cAAc,EAAS,EAAE;aAC1B;SACF;QACD,mBAAmB,EAAE;YACnB,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,WAAW,EAAE,EAAE;SAChB;KACF;IAED,IAAI,EAAE;QACJ,qFAAqF;QACrF,iBAAiB,EAAwB,EAAE;QAC3C,gBAAgB,EAAqB,EAAE;KACxC;IAED,IAAI,EAAE,EAAE;IAER,SAAS,EAAE;QACT,iBAAiB;QAEjB,uEAAuE;QACvE,yGAAyG;QACzG,MAAM,EAAE,UAAU,IAAqB,EAAE,KAAa,EAAE,QAAgB,EAAE,MAAe,EAAE,GAAW,EAAE,IAAyD,EAAE,WAAW,GAAG,KAAK;YACpL,gCAAgC;YAChC,MAAM,SAAS,GAAG,EAAE,GAAG,cAAc,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;YAC9D,SAAS,CAAC,KAAK,GAAG,KAAK,CAAA;YACvB,SAAS,CAAC,QAAQ,GAAG,QAAQ,CAAA;YAC7B,SAAS,CAAC,MAAM,GAAG,MAAM,CAAA;YACzB,SAAS,CAAC,GAAG,GAAG,GAAG,CAAA;YACnB,SAAS,CAAC,W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CAAA;QACzD,CAAC;QAED,iBAAiB;QAEjB,gEAAgE;QAChE,GAAG,EAAE;YACH,OAAO,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAA;QAC9C,CAAC;QAED,kEAAkE;QAClE,WAAW,EAAE,UAAU,IAAqB;YAC1C,OAAO,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;QACpD,CAAC;QAED,iBAAiB,EAAE;YACjB,OAAO,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAA;QAC7C,CAAC;KAEF;CAEF,CAAA;AAYQ,wCAAc;AAVvB,KAAK,UAAU,gBAAgB,CAAC,UAAoB;IAClD,IAAI,cAAc,GAAgB,qCAAiB,CAAC,KAAK,EAAE,CAAA;IAC3D,cAAc,CAAC,OAAO,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnD,cAAc,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAA;IACjE,0BAA0B;IAC1B,cAAc,GAAG,MAAM,qCAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;IAC7D,4BAA4B;IAC5B,OAAO,cAAc,CAAA;AACvB,CAAC;AAEwB,4CAAgB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Socket } from 'socket.io-client';
|
|
2
|
+
import * as skeletons from './utils/skeletons';
|
|
3
|
+
import { DemosWebAuth } from './DemosWebAuth';
|
|
4
|
+
import { prepareXMPayload } from './XMTransactions';
|
|
5
|
+
import { prepareWeb2Payload } from './Web2Transactions';
|
|
6
|
+
import type { Transaction, ValidityData } from '../types';
|
|
7
|
+
export declare const demos: {
|
|
8
|
+
socket: Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap> | null;
|
|
9
|
+
socket_connected: boolean;
|
|
10
|
+
connectedListener: (val: any) => void;
|
|
11
|
+
connected: boolean;
|
|
12
|
+
onConnectedChange: (listener: any) => void;
|
|
13
|
+
identity: null;
|
|
14
|
+
registry: {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
};
|
|
17
|
+
replies: {
|
|
18
|
+
waitReply: (muid: string) => void;
|
|
19
|
+
needReply: (muid: string | number) => boolean;
|
|
20
|
+
getReply: (muid: string | number) => any;
|
|
21
|
+
checkReply: (muid: any, ms?: number) => Promise<any>;
|
|
22
|
+
};
|
|
23
|
+
connect: (rpc_url: string) => void;
|
|
24
|
+
disconnect: () => void;
|
|
25
|
+
generateMuid: () => string;
|
|
26
|
+
nodeCall: (message: any, args?: {}) => Promise<any>;
|
|
27
|
+
confirm: (transaction: Transaction) => Promise<any>;
|
|
28
|
+
broadcast: (validationData: ValidityData) => Promise<any>;
|
|
29
|
+
call: (type: any, message: any, data?: any, extra?: any, sender?: any, receiver?: any) => Promise<any>;
|
|
30
|
+
getLastBlockNumber: () => Promise<any>;
|
|
31
|
+
getLastBlockHash: () => Promise<any>;
|
|
32
|
+
getBlockByNumber: (blockNumber: any) => Promise<any>;
|
|
33
|
+
getBlockByHash: (blockHash: any) => Promise<any>;
|
|
34
|
+
getTxByHash: (txHash?: string) => Promise<any>;
|
|
35
|
+
getPeerlist: () => Promise<any>;
|
|
36
|
+
getMempool: () => Promise<any>;
|
|
37
|
+
getPeerIdentity: () => Promise<any>;
|
|
38
|
+
getAddressInfo: (address: any) => Promise<any>;
|
|
39
|
+
web2: {
|
|
40
|
+
createPayload: typeof prepareWeb2Payload;
|
|
41
|
+
};
|
|
42
|
+
xm: {
|
|
43
|
+
createPayload: typeof prepareXMPayload;
|
|
44
|
+
};
|
|
45
|
+
DemosTransactions: {
|
|
46
|
+
empty: () => Transaction;
|
|
47
|
+
prepare: (data: any) => Promise<Transaction>;
|
|
48
|
+
sign: (raw_tx: Transaction, private_key?: Uint8Array | null) => Promise<Transaction>;
|
|
49
|
+
confirm: (signedPayload: Transaction) => Promise<any>;
|
|
50
|
+
broadcast: (validityData: ValidityData) => Promise<any>;
|
|
51
|
+
};
|
|
52
|
+
transactions: {
|
|
53
|
+
empty: () => Transaction;
|
|
54
|
+
prepare: (data: any) => Promise<Transaction>;
|
|
55
|
+
sign: (raw_tx: Transaction, private_key?: Uint8Array | null) => Promise<Transaction>;
|
|
56
|
+
confirm: (signedPayload: Transaction) => Promise<any>;
|
|
57
|
+
broadcast: (validityData: ValidityData) => Promise<any>;
|
|
58
|
+
};
|
|
59
|
+
DemosWebAuth: typeof DemosWebAuth;
|
|
60
|
+
skeletons: typeof skeletons;
|
|
61
|
+
};
|