@bsv/sdk 1.4.15 → 1.4.18
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/cjs/mod.js +1 -0
- package/dist/cjs/mod.js.map +1 -1
- package/dist/cjs/package.json +9 -9
- package/dist/cjs/src/kvstore/LocalKVStore.js +279 -0
- package/dist/cjs/src/kvstore/LocalKVStore.js.map +1 -0
- package/dist/cjs/src/kvstore/index.js +9 -0
- package/dist/cjs/src/kvstore/index.js.map +1 -0
- package/dist/cjs/src/wallet/WERR_REVIEW_ACTIONS.js +29 -0
- package/dist/cjs/src/wallet/WERR_REVIEW_ACTIONS.js.map +1 -0
- package/dist/cjs/src/wallet/WalletError.js +4 -3
- package/dist/cjs/src/wallet/WalletError.js.map +1 -1
- package/dist/cjs/src/wallet/index.js +4 -1
- package/dist/cjs/src/wallet/index.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js +13 -6
- package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/mod.js +1 -0
- package/dist/esm/mod.js.map +1 -1
- package/dist/esm/src/kvstore/LocalKVStore.js +273 -0
- package/dist/esm/src/kvstore/LocalKVStore.js.map +1 -0
- package/dist/esm/src/kvstore/index.js +2 -0
- package/dist/esm/src/kvstore/index.js.map +1 -0
- package/dist/esm/src/wallet/WERR_REVIEW_ACTIONS.js +31 -0
- package/dist/esm/src/wallet/WERR_REVIEW_ACTIONS.js.map +1 -0
- package/dist/esm/src/wallet/WalletError.js +3 -2
- package/dist/esm/src/wallet/WalletError.js.map +1 -1
- package/dist/esm/src/wallet/index.js +2 -0
- package/dist/esm/src/wallet/index.js.map +1 -1
- package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js +13 -6
- package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/mod.d.ts +1 -0
- package/dist/types/mod.d.ts.map +1 -1
- package/dist/types/src/kvstore/LocalKVStore.d.ts +85 -0
- package/dist/types/src/kvstore/LocalKVStore.d.ts.map +1 -0
- package/dist/types/src/kvstore/index.d.ts +2 -0
- package/dist/types/src/kvstore/index.d.ts.map +1 -0
- package/dist/types/src/wallet/WERR_REVIEW_ACTIONS.d.ts +23 -0
- package/dist/types/src/wallet/WERR_REVIEW_ACTIONS.d.ts.map +1 -0
- package/dist/types/src/wallet/Wallet.interfaces.d.ts +22 -0
- package/dist/types/src/wallet/Wallet.interfaces.d.ts.map +1 -1
- package/dist/types/src/wallet/WalletError.d.ts +4 -3
- package/dist/types/src/wallet/WalletError.d.ts.map +1 -1
- package/dist/types/src/wallet/index.d.ts +1 -0
- package/dist/types/src/wallet/index.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/identity.md +225 -0
- package/docs/kvstore.md +133 -0
- package/docs/registry.md +383 -0
- package/docs/transaction.md +3 -3
- package/docs/wallet.md +146 -38
- package/mod.ts +2 -1
- package/package.json +19 -9
- package/src/kvstore/LocalKVStore.ts +287 -0
- package/src/kvstore/__tests/LocalKVStore.test.ts +614 -0
- package/src/kvstore/index.ts +1 -0
- package/src/wallet/WERR_REVIEW_ACTIONS.ts +30 -0
- package/src/wallet/Wallet.interfaces.ts +24 -0
- package/src/wallet/WalletError.ts +4 -2
- package/src/wallet/index.ts +2 -0
- package/src/wallet/substrates/HTTPWalletJSON.ts +12 -6
- package/docs/wallet-substrates.md +0 -1194
package/dist/cjs/mod.js
CHANGED
|
@@ -32,4 +32,5 @@ __exportStar(require("./src/overlay-tools/index.js"), exports);
|
|
|
32
32
|
__exportStar(require("./src/storage/index.js"), exports);
|
|
33
33
|
__exportStar(require("./src/identity/index.js"), exports);
|
|
34
34
|
__exportStar(require("./src/registry/index.js"), exports);
|
|
35
|
+
__exportStar(require("./src/kvstore/index.js"), exports);
|
|
35
36
|
//# sourceMappingURL=mod.js.map
|
package/dist/cjs/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../mod.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAyC;AACzC,wDAAqC;AACrC,kEAA+C;AAC/C,6DAA0C;AAC1C,wEAAqD;AACrD,0EAAuD;AACvD,2EAAwD;AACxD,kEAA+C;AAC/C,0DAAuC;AACvC,wDAAqC;AACrC,sDAAmC;AACnC,wDAAqC;AACrC,mEAAgD;AAChD,sDAAmC;AACnC,+DAA4C;AAC5C,yDAAsC;AACtC,0DAAuC;AACvC,0DAAuC"}
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../mod.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAyC;AACzC,wDAAqC;AACrC,kEAA+C;AAC/C,6DAA0C;AAC1C,wEAAqD;AACrD,0EAAuD;AACvD,2EAAwD;AACxD,kEAA+C;AAC/C,0DAAuC;AACvC,wDAAqC;AACrC,sDAAmC;AACnC,wDAAqC;AACrC,mEAAgD;AAChD,sDAAmC;AACnC,+DAA4C;AAC5C,yDAAsC;AACtC,0DAAuC;AACvC,0DAAuC;AACvC,yDAAsC"}
|
package/dist/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/sdk",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.18",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "BSV Blockchain Software Development Kit",
|
|
6
6
|
"files": [
|
|
@@ -41,23 +41,23 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/bitcoin-sv/ts-sdk#readme",
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@eslint/js": "^9.
|
|
44
|
+
"@eslint/js": "^9.23.0",
|
|
45
45
|
"@jest/globals": "^29.7.0",
|
|
46
46
|
"@types/jest": "^29.5.14",
|
|
47
47
|
"@types/node": "^22.13.14",
|
|
48
|
-
"eslint": "^
|
|
49
|
-
"globals": "^
|
|
48
|
+
"eslint": "^9.23.0",
|
|
49
|
+
"globals": "^16.0.0",
|
|
50
50
|
"jest": "^29.7.0",
|
|
51
51
|
"jest-environment-jsdom": "^29.7.0",
|
|
52
|
-
"ts-jest": "^29.
|
|
53
|
-
"ts-loader": "^9.5.
|
|
52
|
+
"ts-jest": "^29.3.1",
|
|
53
|
+
"ts-loader": "^9.5.2",
|
|
54
54
|
"ts-standard": "^12.0.2",
|
|
55
55
|
"ts2md": "^0.2.8",
|
|
56
56
|
"tsconfig-to-dual-package": "^1.2.0",
|
|
57
57
|
"typescript": "5.1",
|
|
58
|
-
"typescript-eslint": "^8.
|
|
59
|
-
"webpack": "^5.
|
|
60
|
-
"webpack-cli": "^
|
|
58
|
+
"typescript-eslint": "^8.29.0",
|
|
59
|
+
"webpack": "^5.98.0",
|
|
60
|
+
"webpack-cli": "^6.0.1"
|
|
61
61
|
},
|
|
62
62
|
"ts-standard": {
|
|
63
63
|
"project": "tsconfig.eslint.json",
|
|
@@ -0,0 +1,279 @@
|
|
|
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
|
+
const PushDrop_js_1 = __importDefault(require("../script/templates/PushDrop.js"));
|
|
30
|
+
const Utils = __importStar(require("../primitives/utils.js"));
|
|
31
|
+
const WalletClient_js_1 = __importDefault(require("../wallet/WalletClient.js"));
|
|
32
|
+
const Transaction_js_1 = __importDefault(require("../transaction/Transaction.js"));
|
|
33
|
+
const Beef_js_1 = require("../transaction/Beef.js");
|
|
34
|
+
/**
|
|
35
|
+
* Implements a key-value storage system backed by transaction outputs managed by a wallet.
|
|
36
|
+
* Each key-value pair is represented by a PushDrop token output in a specific context (basket).
|
|
37
|
+
* Allows setting, getting, and removing key-value pairs, with optional encryption.
|
|
38
|
+
*/
|
|
39
|
+
class LocalKVStore {
|
|
40
|
+
/**
|
|
41
|
+
* Creates an instance of the localKVStore.
|
|
42
|
+
*
|
|
43
|
+
* @param {WalletInterface} [wallet=new WalletClient()] - The wallet interface to use. Defaults to a new WalletClient instance.
|
|
44
|
+
* @param {string} [context='kvstoredefault'] - The context (basket) for namespacing keys. Defaults to 'kvstore default'.
|
|
45
|
+
* @param {boolean} [encrypt=true] - Whether to encrypt values. Defaults to true.
|
|
46
|
+
* @param {string} [originator] — An originator to use with PushDrop and the wallet, if provided.
|
|
47
|
+
* @throws {Error} If the context is missing or empty.
|
|
48
|
+
*/
|
|
49
|
+
constructor(wallet = new WalletClient_js_1.default(), context = 'kvstore default', encrypt = true, originator) {
|
|
50
|
+
if (typeof context !== 'string' || context.length < 1) {
|
|
51
|
+
throw new Error('A context in which to operate is required.');
|
|
52
|
+
}
|
|
53
|
+
this.wallet = wallet;
|
|
54
|
+
this.context = context;
|
|
55
|
+
this.encrypt = encrypt;
|
|
56
|
+
this.originator = originator;
|
|
57
|
+
}
|
|
58
|
+
getProtocol(key) {
|
|
59
|
+
return { protocolID: [2, this.context], keyID: key };
|
|
60
|
+
}
|
|
61
|
+
async getOutputs(key, limit) {
|
|
62
|
+
const results = await this.wallet.listOutputs({
|
|
63
|
+
basket: this.context,
|
|
64
|
+
tags: [key],
|
|
65
|
+
tagQueryMode: 'all',
|
|
66
|
+
include: 'entire transactions',
|
|
67
|
+
limit
|
|
68
|
+
});
|
|
69
|
+
return results;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Retrieves the value associated with a given key.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} key - The key to retrieve the value for.
|
|
75
|
+
* @param {string | undefined} [defaultValue=undefined] - The value to return if the key is not found.
|
|
76
|
+
* @returns {Promise<string | undefined>} A promise that resolves to the value as a string,
|
|
77
|
+
* the defaultValue if the key is not found, or undefined if no defaultValue is provided.
|
|
78
|
+
* @throws {Error} If too many outputs are found for the key (ambiguous state).
|
|
79
|
+
* @throws {Error} If the found output's locking script cannot be decoded or represents an invalid token format.
|
|
80
|
+
*/
|
|
81
|
+
async get(key, defaultValue = undefined) {
|
|
82
|
+
const r = await this.lookupValue(key, defaultValue, 5);
|
|
83
|
+
return r.value;
|
|
84
|
+
}
|
|
85
|
+
getLockingScript(output, beef) {
|
|
86
|
+
var _a;
|
|
87
|
+
const [txid, vout] = output.outpoint.split('.');
|
|
88
|
+
const tx = (_a = beef.findTxid(txid)) === null || _a === void 0 ? void 0 : _a.tx;
|
|
89
|
+
if (tx == null) {
|
|
90
|
+
throw new Error(`beef must contain txid ${txid}`);
|
|
91
|
+
}
|
|
92
|
+
const lockingScript = tx.outputs[Number(vout)].lockingScript;
|
|
93
|
+
return lockingScript;
|
|
94
|
+
}
|
|
95
|
+
async lookupValue(key, defaultValue, limit) {
|
|
96
|
+
const lor = await this.getOutputs(key, limit);
|
|
97
|
+
const r = { value: defaultValue, outpoint: undefined, lor };
|
|
98
|
+
const { outputs } = lor;
|
|
99
|
+
if (outputs.length === 0) {
|
|
100
|
+
return r;
|
|
101
|
+
}
|
|
102
|
+
const output = outputs.slice(-1)[0];
|
|
103
|
+
r.outpoint = output.outpoint;
|
|
104
|
+
let field;
|
|
105
|
+
try {
|
|
106
|
+
if (lor.BEEF === undefined) {
|
|
107
|
+
throw new Error('entire transactions listOutputs option must return valid BEEF');
|
|
108
|
+
}
|
|
109
|
+
const lockingScript = this.getLockingScript(output, Beef_js_1.Beef.fromBinary(lor.BEEF));
|
|
110
|
+
const decoded = PushDrop_js_1.default.decode(lockingScript);
|
|
111
|
+
if (decoded.fields.length < 1 || decoded.fields.length > 2) {
|
|
112
|
+
throw new Error('Invalid token.');
|
|
113
|
+
}
|
|
114
|
+
field = decoded.fields[0];
|
|
115
|
+
}
|
|
116
|
+
catch (_) {
|
|
117
|
+
throw new Error(`Invalid value found. You need to call set to collapse the corrupted state (or relinquish the corrupted ${outputs[0].outpoint} output from the ${this.context} basket) before you can get this value again.`);
|
|
118
|
+
}
|
|
119
|
+
if (!this.encrypt) {
|
|
120
|
+
r.value = Utils.toUTF8(field);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const { plaintext } = await this.wallet.decrypt({
|
|
124
|
+
...this.getProtocol(key),
|
|
125
|
+
ciphertext: field
|
|
126
|
+
});
|
|
127
|
+
r.value = Utils.toUTF8(plaintext);
|
|
128
|
+
}
|
|
129
|
+
return r;
|
|
130
|
+
}
|
|
131
|
+
getInputs(outputs) {
|
|
132
|
+
const inputs = [];
|
|
133
|
+
for (let i = 0; i < outputs.length; i++) {
|
|
134
|
+
inputs.push({
|
|
135
|
+
outpoint: outputs[i].outpoint,
|
|
136
|
+
unlockingScriptLength: 74,
|
|
137
|
+
inputDescription: 'Previous key-value token'
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return inputs;
|
|
141
|
+
}
|
|
142
|
+
async getSpends(key, outputs, pushdrop, atomicBEEF) {
|
|
143
|
+
const p = this.getProtocol(key);
|
|
144
|
+
const tx = Transaction_js_1.default.fromAtomicBEEF(atomicBEEF);
|
|
145
|
+
const spends = {};
|
|
146
|
+
for (let i = 0; i < outputs.length; i++) {
|
|
147
|
+
const unlocker = pushdrop.unlock(p.protocolID, p.keyID, 'self');
|
|
148
|
+
const unlockingScript = await unlocker.sign(tx, i);
|
|
149
|
+
spends[i] = {
|
|
150
|
+
unlockingScript: unlockingScript.toHex()
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return spends;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Sets or updates the value associated with a given key.
|
|
157
|
+
* If the key already exists (one or more outputs found), it spends the existing output(s)
|
|
158
|
+
* and creates a new one with the updated value. If multiple outputs exist for the key,
|
|
159
|
+
* they are collapsed into a single new output.
|
|
160
|
+
* If the key does not exist, it creates a new output.
|
|
161
|
+
* Handles encryption if enabled.
|
|
162
|
+
* If signing the update/collapse transaction fails, it relinquishes the original outputs and starts over with a new chain.
|
|
163
|
+
*
|
|
164
|
+
* @param {string} key - The key to set or update.
|
|
165
|
+
* @param {string} value - The value to associate with the key.
|
|
166
|
+
* @returns {Promise<OutpointString>} A promise that resolves to the outpoint string (txid.vout) of the new or updated token output.
|
|
167
|
+
*/
|
|
168
|
+
async set(key, value) {
|
|
169
|
+
const current = await this.lookupValue(key, undefined, 10);
|
|
170
|
+
if (current.value === value) {
|
|
171
|
+
if (current.outpoint === undefined) {
|
|
172
|
+
throw new Error('outpoint must be valid when value is valid and unchanged');
|
|
173
|
+
}
|
|
174
|
+
// Don't create a new transaction if the value doesn't need to change...
|
|
175
|
+
return current.outpoint;
|
|
176
|
+
}
|
|
177
|
+
const protocol = this.getProtocol(key);
|
|
178
|
+
let valueAsArray = Utils.toArray(value, 'utf8');
|
|
179
|
+
if (this.encrypt) {
|
|
180
|
+
const { ciphertext } = await this.wallet.encrypt({
|
|
181
|
+
...protocol,
|
|
182
|
+
plaintext: valueAsArray
|
|
183
|
+
});
|
|
184
|
+
valueAsArray = ciphertext;
|
|
185
|
+
}
|
|
186
|
+
const pushdrop = new PushDrop_js_1.default(this.wallet, this.originator);
|
|
187
|
+
const lockingScript = await pushdrop.lock([valueAsArray], protocol.protocolID, protocol.keyID, 'self');
|
|
188
|
+
const { outputs, BEEF: inputBEEF } = current.lor;
|
|
189
|
+
let outpoint;
|
|
190
|
+
try {
|
|
191
|
+
const inputs = this.getInputs(outputs);
|
|
192
|
+
const { txid, signableTransaction } = await this.wallet.createAction({
|
|
193
|
+
description: `Update ${key} in ${this.context}`,
|
|
194
|
+
inputBEEF,
|
|
195
|
+
inputs,
|
|
196
|
+
outputs: [{
|
|
197
|
+
basket: this.context,
|
|
198
|
+
tags: [key],
|
|
199
|
+
lockingScript: lockingScript.toHex(),
|
|
200
|
+
satoshis: 1,
|
|
201
|
+
outputDescription: 'Key-value token'
|
|
202
|
+
}],
|
|
203
|
+
options: {
|
|
204
|
+
acceptDelayedBroadcast: false,
|
|
205
|
+
randomizeOutputs: false
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
if (outputs.length > 0 && typeof signableTransaction !== 'object') {
|
|
209
|
+
throw new Error('Wallet did not return a signable transaction when expected.');
|
|
210
|
+
}
|
|
211
|
+
if (signableTransaction == null) {
|
|
212
|
+
outpoint = `${txid}.0`;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
const spends = await this.getSpends(key, outputs, pushdrop, signableTransaction.tx);
|
|
216
|
+
const { txid } = await this.wallet.signAction({
|
|
217
|
+
reference: signableTransaction.reference,
|
|
218
|
+
spends
|
|
219
|
+
});
|
|
220
|
+
outpoint = `${txid}.0`;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch (_) {
|
|
224
|
+
throw new Error(`There are ${outputs.length} outputs with tag ${key} that cannot be unlocked.`);
|
|
225
|
+
}
|
|
226
|
+
return outpoint;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Removes the key-value pair associated with the given key.
|
|
230
|
+
* It finds the existing output(s) for the key and spends them without creating a new output.
|
|
231
|
+
* If multiple outputs exist, they are all spent in the same transaction.
|
|
232
|
+
* If the key does not exist, it does nothing.
|
|
233
|
+
* If signing the removal transaction fails, it relinquishes the original outputs instead of spending.
|
|
234
|
+
*
|
|
235
|
+
* @param {string} key - The key to remove.
|
|
236
|
+
* @returns {Promise<string[]>} A promise that resolves to the txids of the removal transactions if successful.
|
|
237
|
+
*/
|
|
238
|
+
async remove(key) {
|
|
239
|
+
const txids = [];
|
|
240
|
+
for (;;) {
|
|
241
|
+
const { outputs, BEEF: inputBEEF, totalOutputs } = await this.getOutputs(key);
|
|
242
|
+
if (outputs.length > 0) {
|
|
243
|
+
const pushdrop = new PushDrop_js_1.default(this.wallet, this.originator);
|
|
244
|
+
try {
|
|
245
|
+
const inputs = this.getInputs(outputs);
|
|
246
|
+
const { signableTransaction } = await this.wallet.createAction({
|
|
247
|
+
description: `Remove ${key} in ${this.context}`,
|
|
248
|
+
inputBEEF,
|
|
249
|
+
inputs,
|
|
250
|
+
options: {
|
|
251
|
+
acceptDelayedBroadcast: false
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
if (typeof signableTransaction !== 'object') {
|
|
255
|
+
throw new Error('Wallet did not return a signable transaction when expected.');
|
|
256
|
+
}
|
|
257
|
+
const spends = await this.getSpends(key, outputs, pushdrop, signableTransaction.tx);
|
|
258
|
+
const { txid } = await this.wallet.signAction({
|
|
259
|
+
reference: signableTransaction.reference,
|
|
260
|
+
spends
|
|
261
|
+
});
|
|
262
|
+
if (txid === undefined) {
|
|
263
|
+
throw new Error('signAction must return a valid txid');
|
|
264
|
+
}
|
|
265
|
+
txids.push(txid);
|
|
266
|
+
}
|
|
267
|
+
catch (_) {
|
|
268
|
+
throw new Error(`There are ${totalOutputs} outputs with tag ${key} that cannot be unlocked.`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (outputs.length === totalOutputs) {
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return txids;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
exports.default = LocalKVStore;
|
|
279
|
+
//# sourceMappingURL=LocalKVStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalKVStore.js","sourceRoot":"","sources":["../../../../src/kvstore/LocalKVStore.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kFAAsD;AACtD,8DAA+C;AAE/C,gFAAoD;AACpD,mFAAuD;AACvD,oDAA6C;AAE7C;;;;GAIG;AACH,MAAqB,YAAY;IA2B/B;;;;;;;;OAQG;IACH,YACE,SAA0B,IAAI,yBAAY,EAAE,EAC5C,OAAO,GAAG,iBAAiB,EAC3B,OAAO,GAAG,IAAI,EACd,UAAmB;QAEnB,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACrD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;SAC9D;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAEO,WAAW,CAAE,GAAW;QAC9B,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,I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IAAI,KAAK,CAAC,aAAa,YAAY,qBAAqB,GAAG,2BAA2B,CAAC,CAAA;iBAC9F;aACF;YACD,IAAI,OAAO,CAAC,MAAM,KAAK,YAAY,EAAE;gBAAE,MAAK;aAAE;SAC/C;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AA3QD,+BA2QC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LocalKVStore = void 0;
|
|
7
|
+
var LocalKVStore_js_1 = require("./LocalKVStore.js");
|
|
8
|
+
Object.defineProperty(exports, "LocalKVStore", { enumerable: true, get: function () { return __importDefault(LocalKVStore_js_1).default; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/kvstore/index.ts"],"names":[],"mappings":";;;;;;AAAA,qDAA2D;AAAlD,gIAAA,OAAO,OAAgB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WERR_REVIEW_ACTIONS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* When a `createAction` or `signAction` is completed in undelayed mode (`acceptDelayedBroadcast`: false),
|
|
6
|
+
* any unsucccessful result will return the results by way of this exception to ensure attention is
|
|
7
|
+
* paid to processing errors.
|
|
8
|
+
*/
|
|
9
|
+
class WERR_REVIEW_ACTIONS extends Error {
|
|
10
|
+
/**
|
|
11
|
+
* All parameters correspond to their comparable `createAction` or `signSction` results
|
|
12
|
+
* with the exception of `reviewActionResults`;
|
|
13
|
+
* which contains more details, particularly for double spend results.
|
|
14
|
+
*/
|
|
15
|
+
constructor(reviewActionResults, sendWithResults, txid, tx, noSendChange) {
|
|
16
|
+
super('Undelayed createAction or signAction results require review.');
|
|
17
|
+
this.reviewActionResults = reviewActionResults;
|
|
18
|
+
this.sendWithResults = sendWithResults;
|
|
19
|
+
this.txid = txid;
|
|
20
|
+
this.tx = tx;
|
|
21
|
+
this.noSendChange = noSendChange;
|
|
22
|
+
this.isError = true;
|
|
23
|
+
this.code = 5;
|
|
24
|
+
this.name = this.constructor.name;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.WERR_REVIEW_ACTIONS = WERR_REVIEW_ACTIONS;
|
|
28
|
+
exports.default = WERR_REVIEW_ACTIONS;
|
|
29
|
+
//# sourceMappingURL=WERR_REVIEW_ACTIONS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WERR_REVIEW_ACTIONS.js","sourceRoot":"","sources":["../../../../src/wallet/WERR_REVIEW_ACTIONS.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH,MAAa,mBAAoB,SAAQ,KAAK;IAI5C;;;;OAIG;IACH,YACS,mBAAyC,EACzC,eAAiC,EACjC,IAAoB,EACpB,EAAe,EACf,YAA+B;QAEtC,KAAK,CAAC,8DAA8D,CAAC,CAAA;QAN9D,wBAAmB,GAAnB,mBAAmB,CAAsB;QACzC,oBAAe,GAAf,eAAe,CAAkB;QACjC,SAAI,GAAJ,IAAI,CAAgB;QACpB,OAAE,GAAF,EAAE,CAAa;QACf,iBAAY,GAAZ,YAAY,CAAmB;QAZxC,YAAO,GAAY,IAAI,CAAA;QAerB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAA;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;IACnC,CAAC;CACF;AApBD,kDAoBC;AAED,kBAAe,mBAAmB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WalletError = void 0;
|
|
3
|
+
exports.walletErrors = exports.WalletError = void 0;
|
|
4
4
|
class WalletError extends Error {
|
|
5
5
|
constructor(message, code = 1, stack) {
|
|
6
6
|
super(message);
|
|
@@ -23,6 +23,7 @@ var walletErrors;
|
|
|
23
23
|
walletErrors[walletErrors["unsupportedAction"] = 2] = "unsupportedAction";
|
|
24
24
|
walletErrors[walletErrors["invalidHmac"] = 3] = "invalidHmac";
|
|
25
25
|
walletErrors[walletErrors["invalidSignature"] = 4] = "invalidSignature";
|
|
26
|
-
|
|
27
|
-
exports.
|
|
26
|
+
walletErrors[walletErrors["reviewActions"] = 5] = "reviewActions";
|
|
27
|
+
})(walletErrors || (exports.walletErrors = walletErrors = {}));
|
|
28
|
+
exports.default = WalletError;
|
|
28
29
|
//# sourceMappingURL=WalletError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WalletError.js","sourceRoot":"","sources":["../../../../src/wallet/WalletError.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAY,SAAQ,KAAK;IAIpC,YAAa,OAAe,EAAE,IAAI,GAAG,CAAC,EAAE,KAAc;QACpD,KAAK,CAAC,OAAO,CAAC,CAAA;QAHhB,YAAO,GAAY,IAAI,CAAA;QAIrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QAEjC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE;YACzD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;SACnB;aAAM;YACL,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;SAChD;IACH,CAAC;CACF;AAfD,kCAeC;AAED,4DAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"WalletError.js","sourceRoot":"","sources":["../../../../src/wallet/WalletError.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAY,SAAQ,KAAK;IAIpC,YAAa,OAAe,EAAE,IAAI,GAAG,CAAC,EAAE,KAAc;QACpD,KAAK,CAAC,OAAO,CAAC,CAAA;QAHhB,YAAO,GAAY,IAAI,CAAA;QAIrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QAEjC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE;YACzD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;SACnB;aAAM;YACL,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;SAChD;IACH,CAAC;CACF;AAfD,kCAeC;AAED,4DAA4D;AAC5D,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,+DAAgB,CAAA;IAChB,yEAAqB,CAAA;IACrB,6DAAe,CAAA;IACf,uEAAoB,CAAA;IACpB,iEAAiB,CAAA;AACnB,CAAC,EANW,YAAY,4BAAZ,YAAY,QAMvB;AAID,kBAAe,WAAW,CAAA"}
|
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.WalletErrors = exports.WalletClient = exports.ProtoWallet = exports.CachedKeyDeriver = void 0;
|
|
20
|
+
exports.WERR_REVIEW_ACTIONS = exports.WalletErrors = exports.WalletClient = exports.ProtoWallet = exports.CachedKeyDeriver = void 0;
|
|
21
21
|
__exportStar(require("./Wallet.interfaces.js"), exports);
|
|
22
22
|
__exportStar(require("./KeyDeriver.js"), exports);
|
|
23
23
|
var CachedKeyDeriver_js_1 = require("./CachedKeyDeriver.js");
|
|
@@ -26,8 +26,11 @@ var ProtoWallet_js_1 = require("./ProtoWallet.js");
|
|
|
26
26
|
Object.defineProperty(exports, "ProtoWallet", { enumerable: true, get: function () { return __importDefault(ProtoWallet_js_1).default; } });
|
|
27
27
|
var WalletClient_js_1 = require("./WalletClient.js");
|
|
28
28
|
Object.defineProperty(exports, "WalletClient", { enumerable: true, get: function () { return __importDefault(WalletClient_js_1).default; } });
|
|
29
|
+
// Is this an error? should it be 'walletErrors', the enum not the class?
|
|
29
30
|
var WalletError_js_1 = require("./WalletError.js");
|
|
30
31
|
Object.defineProperty(exports, "WalletErrors", { enumerable: true, get: function () { return __importDefault(WalletError_js_1).default; } });
|
|
32
|
+
var WERR_REVIEW_ACTIONS_js_1 = require("./WERR_REVIEW_ACTIONS.js");
|
|
33
|
+
Object.defineProperty(exports, "WERR_REVIEW_ACTIONS", { enumerable: true, get: function () { return __importDefault(WERR_REVIEW_ACTIONS_js_1).default; } });
|
|
31
34
|
__exportStar(require("./WalletError.js"), exports);
|
|
32
35
|
__exportStar(require("./substrates/index.js"), exports);
|
|
33
36
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/wallet/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,yDAAsC;AACtC,kDAA+B;AAC/B,6DAAmE;AAA1D,wIAAA,OAAO,OAAoB;AACpC,mDAAyD;AAAhD,8HAAA,OAAO,OAAe;AAC/B,qDAA2D;AAAlD,gIAAA,OAAO,OAAgB;AAChC,mDAA0D;AAAjD,+HAAA,OAAO,OAAgB;AAChC,mDAAgC;AAChC,wDAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/wallet/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,yDAAsC;AACtC,kDAA+B;AAC/B,6DAAmE;AAA1D,wIAAA,OAAO,OAAoB;AACpC,mDAAyD;AAAhD,8HAAA,OAAO,OAAe;AAC/B,qDAA2D;AAAlD,gIAAA,OAAO,OAAgB;AAChC,yEAAyE;AACzE,mDAA0D;AAAjD,+HAAA,OAAO,OAAgB;AAChC,mEAAyE;AAAhE,8IAAA,OAAO,OAAuB;AACvC,mDAAgC;AAChC,wDAAqC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const WERR_REVIEW_ACTIONS_js_1 = require("../WERR_REVIEW_ACTIONS.js");
|
|
3
4
|
class HTTPWalletJSON {
|
|
4
5
|
constructor(originator, baseUrl = 'http://localhost:3321', httpClient = fetch) {
|
|
5
6
|
this.baseUrl = baseUrl;
|
|
@@ -19,12 +20,18 @@ class HTTPWalletJSON {
|
|
|
19
20
|
const data = await res.json();
|
|
20
21
|
// Check the HTTP status on the original response
|
|
21
22
|
if (!res.ok) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
if (res.status === 400 && data.isError && data.code === 5) {
|
|
24
|
+
const err = new WERR_REVIEW_ACTIONS_js_1.WERR_REVIEW_ACTIONS(data.reviewActionResults, data.sendWithResults, data.txid, data.tx, data.noSendChange);
|
|
25
|
+
throw err;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const err = {
|
|
29
|
+
call,
|
|
30
|
+
args,
|
|
31
|
+
message: (_b = data.message) !== null && _b !== void 0 ? _b : `HTTP Client error ${res.status}`
|
|
32
|
+
};
|
|
33
|
+
throw new Error(JSON.stringify(err));
|
|
34
|
+
}
|
|
28
35
|
}
|
|
29
36
|
return data;
|
|
30
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HTTPWalletJSON.js","sourceRoot":"","sources":["../../../../../src/wallet/substrates/HTTPWalletJSON.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"HTTPWalletJSON.js","sourceRoot":"","sources":["../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