@wharfkit/transact-plugin-resource-provider 0.3.0-ui-5 → 0.3.0-ui-14
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 +53 -2
- package/lib/transact-plugin-resource-provider.d.ts +13 -5
- package/lib/transact-plugin-resource-provider.js +96 -81
- package/lib/transact-plugin-resource-provider.js.map +1 -1
- package/lib/transact-plugin-resource-provider.m.js +88 -64
- package/lib/transact-plugin-resource-provider.m.js.map +1 -1
- package/package.json +5 -3
- package/src/index.ts +110 -48
- package/lib/resource-provider-plugin.d.ts +0 -84
- package/lib/resource-provider-plugin.js +0 -322
- package/lib/resource-provider-plugin.js.map +0 -1
- package/lib/resource-provider-plugin.m.js +0 -302
- package/lib/resource-provider-plugin.m.js.map +0 -1
- package/lib/resource-provider-plugin.umd.js +0 -303
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @wharfkit/transact-plugin-resource-provider v0.3.0-ui-
|
|
2
|
+
* @wharfkit/transact-plugin-resource-provider v0.3.0-ui-14
|
|
3
3
|
* https://github.com/wharfkit/transact-plugin-resource-provider
|
|
4
4
|
*
|
|
5
5
|
* @license
|
|
@@ -33,29 +33,8 @@
|
|
|
33
33
|
* YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT DESIGNED, LICENSED OR INTENDED FOR USE
|
|
34
34
|
* IN THE DESIGN, CONSTRUCTION, OPERATION OR MAINTENANCE OF ANY MILITARY FACILITY.
|
|
35
35
|
*/
|
|
36
|
-
import {
|
|
37
|
-
|
|
38
|
-
/******************************************************************************
|
|
39
|
-
Copyright (c) Microsoft Corporation.
|
|
40
|
-
|
|
41
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
42
|
-
purpose with or without fee is hereby granted.
|
|
43
|
-
|
|
44
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
45
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
46
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
47
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
48
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
49
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
50
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
51
|
-
***************************************************************************** */
|
|
52
|
-
|
|
53
|
-
function __decorate(decorators, target, key, desc) {
|
|
54
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
55
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
56
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
57
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
58
|
-
}
|
|
36
|
+
import { __decorate } from 'tslib';
|
|
37
|
+
import { Struct, Name, Asset, AbstractTransactPlugin, TransactHookTypes, Serializer, Signature, Canceled, Transaction } from '@wharfkit/session';
|
|
59
38
|
|
|
60
39
|
function hasOriginalActions(original, modified) {
|
|
61
40
|
return original.actions.every((originalAction) => {
|
|
@@ -115,26 +94,40 @@ __decorate([
|
|
|
115
94
|
Transfer = __decorate([
|
|
116
95
|
Struct.type('transfer')
|
|
117
96
|
], Transfer);
|
|
118
|
-
|
|
97
|
+
const defaultOptions = {
|
|
98
|
+
endpoints: {
|
|
99
|
+
aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906: 'https://eos.greymass.com',
|
|
100
|
+
'73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d': 'https://jungle4.greymass.com',
|
|
101
|
+
'4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11': 'https://telos.greymass.com',
|
|
102
|
+
'1064487b3cd1a897ce03ae5b6a865651747e2e152090f99c1d19d44e01aea5a4': 'https://wax.greymass.com',
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
class TransactPluginResourceProvider extends AbstractTransactPlugin {
|
|
119
106
|
constructor(options) {
|
|
120
107
|
super();
|
|
121
|
-
this.allowFees =
|
|
122
|
-
this.endpoints =
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
108
|
+
this.allowFees = true;
|
|
109
|
+
this.endpoints = defaultOptions.endpoints;
|
|
110
|
+
if (options) {
|
|
111
|
+
// Set the endpoints and chains available
|
|
112
|
+
if (options.endpoints) {
|
|
113
|
+
this.endpoints = options.endpoints;
|
|
114
|
+
}
|
|
115
|
+
if (typeof options.allowFees !== 'undefined') {
|
|
116
|
+
this.allowFees = options.allowFees;
|
|
117
|
+
}
|
|
118
|
+
if (typeof options.maxFee !== 'undefined') {
|
|
119
|
+
this.maxFee = Asset.from(options.maxFee);
|
|
120
|
+
}
|
|
121
|
+
// TODO: Allow contact/action combos to be passed in and checked against to ensure no rogue actions were appended.
|
|
122
|
+
// if (typeof options.allowActions !== 'undefined') {
|
|
123
|
+
// this.allowActions = options.allowActions.map((action) => Name.from(action))
|
|
124
|
+
// }
|
|
134
125
|
}
|
|
135
126
|
}
|
|
136
127
|
register(context) {
|
|
137
|
-
context.addHook(TransactHookTypes.beforeSign, (request, context) =>
|
|
128
|
+
context.addHook(TransactHookTypes.beforeSign, async (request, context) => {
|
|
129
|
+
return this.request(request, context);
|
|
130
|
+
});
|
|
138
131
|
}
|
|
139
132
|
getEndpoint(chain) {
|
|
140
133
|
return this.endpoints[String(chain.id)];
|
|
@@ -172,8 +165,10 @@ class ResourceProviderPlugin extends AbstractTransactPlugin {
|
|
|
172
165
|
if (requiresPayment) {
|
|
173
166
|
// If the resource provider offered transaction with a fee, but plugin doesn't allow fees, return the original transaction.
|
|
174
167
|
if (!this.allowFees) {
|
|
175
|
-
// TODO: Notify the script somehow of this, maybe we need an optional logger?
|
|
176
168
|
// Notify that a fee was required but not allowed via allowFees: false.
|
|
169
|
+
if (context.ui) {
|
|
170
|
+
context.ui.status('Resource provider rejected transaction, fee required to proceed and the application disallowed fees.');
|
|
171
|
+
}
|
|
177
172
|
return {
|
|
178
173
|
request,
|
|
179
174
|
};
|
|
@@ -184,8 +179,10 @@ class ResourceProviderPlugin extends AbstractTransactPlugin {
|
|
|
184
179
|
// Ensure the new transaction has an unmodified version of the original action(s)
|
|
185
180
|
const originalActionsIntact = hasOriginalActions(request.getRawTransaction(), modifiedTransaction);
|
|
186
181
|
if (!originalActionsIntact) {
|
|
187
|
-
// TODO: Notify the script somehow of this, maybe we need an optional logger?
|
|
188
182
|
// Notify that the original actions requested were modified somehow, and reject the modification.
|
|
183
|
+
if (context.ui) {
|
|
184
|
+
context.ui.status('Resource provider rejected transaction, it was modified.');
|
|
185
|
+
}
|
|
189
186
|
return {
|
|
190
187
|
request,
|
|
191
188
|
};
|
|
@@ -207,8 +204,10 @@ class ResourceProviderPlugin extends AbstractTransactPlugin {
|
|
|
207
204
|
// If the resource provider offered transaction with a fee, but the fee was higher than allowed, return the original transaction.
|
|
208
205
|
if (this.maxFee) {
|
|
209
206
|
if (addedFees.units > this.maxFee.units) {
|
|
210
|
-
// TODO: Notify the script somehow of this, maybe we need an optional logger?
|
|
211
207
|
// Notify that a fee was required but higher than allowed via maxFee.
|
|
208
|
+
if (context.ui) {
|
|
209
|
+
context.ui.status('Resource provider rejected transaction, the fee amount was an unusually high amount.');
|
|
210
|
+
}
|
|
212
211
|
return {
|
|
213
212
|
request,
|
|
214
213
|
};
|
|
@@ -216,31 +215,56 @@ class ResourceProviderPlugin extends AbstractTransactPlugin {
|
|
|
216
215
|
}
|
|
217
216
|
// Validate that the response is valid for the session.
|
|
218
217
|
await this.validateResponseData(json);
|
|
219
|
-
// NYI: Interact with interface via context for fee based prompting
|
|
220
|
-
/* Psuedo-code for fee based prompting
|
|
221
|
-
|
|
222
|
-
if (response.status === 402) {
|
|
223
|
-
|
|
224
|
-
// Prompt for the fee acceptance
|
|
225
|
-
const promptResponse = context.userPrompt({
|
|
226
|
-
title: 'Transaction Fee Required',
|
|
227
|
-
message: `This transaction requires a fee of ${response.json.data.fee} EOS. Do you wish to accept this fee?`,
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
// If the user did not accept the fee, return the original request without modification.
|
|
231
|
-
if (!promptResponse) {
|
|
232
|
-
return {
|
|
233
|
-
request,
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
} */
|
|
237
218
|
// Create a new signing request based on the response to return to the session's transact flow.
|
|
238
219
|
const modified = await this.createRequest(json, context);
|
|
220
|
+
if (context.ui && addedFees.value > 0) {
|
|
221
|
+
// Initiate a new cancelable prompt to inform the user of the fee required
|
|
222
|
+
const prompt = context.ui.prompt({
|
|
223
|
+
title: 'Fee Required',
|
|
224
|
+
body: 'Resources are required to complete this transaction. Accept fee?',
|
|
225
|
+
elements: [
|
|
226
|
+
{
|
|
227
|
+
type: 'asset',
|
|
228
|
+
data: {
|
|
229
|
+
label: 'Fee required',
|
|
230
|
+
value: addedFees,
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
type: 'accept',
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
});
|
|
238
|
+
// TODO: Set the timer to match the expiration of the transaction
|
|
239
|
+
const timer = setTimeout(() => {
|
|
240
|
+
prompt.cancel('canceled automatically through timeout');
|
|
241
|
+
}, 120000);
|
|
242
|
+
// Return the promise from the prompt
|
|
243
|
+
return prompt
|
|
244
|
+
.then(async () => {
|
|
245
|
+
// Return the modified transaction and additional signatures
|
|
246
|
+
return new Promise((r) => r({
|
|
247
|
+
request: modified,
|
|
248
|
+
signatures: json.data.signatures.map((sig) => Signature.from(sig)),
|
|
249
|
+
}));
|
|
250
|
+
})
|
|
251
|
+
.catch((e) => {
|
|
252
|
+
// Throw if what we caught was a cancelation
|
|
253
|
+
if (e instanceof Canceled) {
|
|
254
|
+
throw e;
|
|
255
|
+
}
|
|
256
|
+
// Otherwise if it wasn't a cancel, it was a reject, and continue without modification
|
|
257
|
+
return new Promise((r) => r({ request }));
|
|
258
|
+
})
|
|
259
|
+
.finally(() => {
|
|
260
|
+
clearTimeout(timer); // TODO: Remove this, it's just here for testing
|
|
261
|
+
});
|
|
262
|
+
}
|
|
239
263
|
// Return the modified transaction and additional signatures
|
|
240
|
-
return {
|
|
264
|
+
return new Promise((r) => r({
|
|
241
265
|
request: modified,
|
|
242
266
|
signatures: json.data.signatures.map((sig) => Signature.from(sig)),
|
|
243
|
-
};
|
|
267
|
+
}));
|
|
244
268
|
}
|
|
245
269
|
getModifiedTransaction(json) {
|
|
246
270
|
switch (json.data.request[0]) {
|
|
@@ -255,7 +279,7 @@ class ResourceProviderPlugin extends AbstractTransactPlugin {
|
|
|
255
279
|
}
|
|
256
280
|
async createRequest(response, context) {
|
|
257
281
|
// Create a new signing request based on the response to return to the session's transact flow.
|
|
258
|
-
const request = await
|
|
282
|
+
const request = await context.createRequest(response.data.request[1]);
|
|
259
283
|
// Set the required fee onto the request itself for wallets to process.
|
|
260
284
|
if (response.code === 402 && response.data.fee) {
|
|
261
285
|
request.setInfoKey('txfee', Asset.from(response.data.fee));
|
|
@@ -298,5 +322,5 @@ class ResourceProviderPlugin extends AbstractTransactPlugin {
|
|
|
298
322
|
}
|
|
299
323
|
}
|
|
300
324
|
|
|
301
|
-
export { Transfer,
|
|
325
|
+
export { TransactPluginResourceProvider, Transfer, defaultOptions };
|
|
302
326
|
//# sourceMappingURL=transact-plugin-resource-provider.m.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transact-plugin-resource-provider.m.js","sources":["../node_modules/tslib/tslib.es6.js","../src/utils.ts","../src/index.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n",null,null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AAE,CAAC,CAAC,CAAC,CAAA;QAC9C,MAAM,eAAe,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,CAAA;AACpD,QAAA,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;AAC9D,YAAA,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAA;AAC1F,SAAA;KACJ;AACD;;AAEG;IACH,MAAM,oBAAoB,CAAC,QAA6B,EAAA;;QAEpD,IAAI,CAAC,QAAQ,EAAE;AACX,YAAA,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;AACvE,SAAA;;AAGD,QAAA,IAAI,QAAQ,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE;AAC7C,YAAA,MAAM,IAAI,KAAK,CACX,gGAAgG,CACnG,CAAA;AACJ,SAAA;;AAGD,QAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;AAC3D,YAAA,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;AACnE,SAAA;KACJ;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wharfkit/transact-plugin-resource-provider",
|
|
3
3
|
"description": "Plugin to automatically provide network resources for transactions using the Resource Provider implementation standard.",
|
|
4
|
-
"version": "0.3.0-ui-
|
|
4
|
+
"version": "0.3.0-ui-14",
|
|
5
5
|
"homepage": "https://github.com/wharfkit/transact-plugin-resource-provider",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "lib/transact-plugin-resource-provider.js",
|
|
8
8
|
"module": "lib/transact-plugin-resource-provider.m.js",
|
|
9
|
-
"browser": "lib/transact-plugin-resource-provider.umd.js",
|
|
10
9
|
"types": "lib/transact-plugin-resource-provider.d.ts",
|
|
11
10
|
"sideEffects": false,
|
|
12
11
|
"files": [
|
|
@@ -16,6 +15,9 @@
|
|
|
16
15
|
"scripts": {
|
|
17
16
|
"prepare": "make"
|
|
18
17
|
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"tslib": "^2.1.0"
|
|
20
|
+
},
|
|
19
21
|
"peerDependencies": {
|
|
20
22
|
"@wharfkit/session": "^0.3.0-ui-13"
|
|
21
23
|
},
|
|
@@ -35,7 +37,7 @@
|
|
|
35
37
|
"@types/node": "^18.7.18",
|
|
36
38
|
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
37
39
|
"@typescript-eslint/parser": "^5.20.0",
|
|
38
|
-
"@wharfkit/session": "^0.3.0-ui-
|
|
40
|
+
"@wharfkit/session": "^0.3.0-ui-14",
|
|
39
41
|
"@wharfkit/wallet-plugin-privatekey": "^0.3.0-ui-13.1",
|
|
40
42
|
"chai": "^4.3.4",
|
|
41
43
|
"eslint": "^8.13.0",
|
package/src/index.ts
CHANGED
|
@@ -3,8 +3,11 @@ import {
|
|
|
3
3
|
Action,
|
|
4
4
|
Asset,
|
|
5
5
|
AssetType,
|
|
6
|
+
Cancelable,
|
|
7
|
+
Canceled,
|
|
6
8
|
ChainDefinition,
|
|
7
9
|
Name,
|
|
10
|
+
PromptResponse,
|
|
8
11
|
Serializer,
|
|
9
12
|
Signature,
|
|
10
13
|
SigningRequest,
|
|
@@ -20,7 +23,7 @@ import {getNewActions, hasOriginalActions} from './utils'
|
|
|
20
23
|
interface ResourceProviderOptions {
|
|
21
24
|
allowFees?: boolean
|
|
22
25
|
// allowActions?: NameType[]
|
|
23
|
-
endpoints
|
|
26
|
+
endpoints?: Record<string, string>
|
|
24
27
|
maxFee?: AssetType
|
|
25
28
|
}
|
|
26
29
|
|
|
@@ -48,36 +51,58 @@ export class Transfer extends Struct {
|
|
|
48
51
|
@Struct.field(Asset) quantity!: Asset
|
|
49
52
|
@Struct.field('string') memo!: string
|
|
50
53
|
}
|
|
54
|
+
export const defaultOptions = {
|
|
55
|
+
endpoints: {
|
|
56
|
+
aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906:
|
|
57
|
+
'https://eos.greymass.com',
|
|
58
|
+
'73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d':
|
|
59
|
+
'https://jungle4.greymass.com',
|
|
60
|
+
'4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11':
|
|
61
|
+
'https://telos.greymass.com',
|
|
62
|
+
'1064487b3cd1a897ce03ae5b6a865651747e2e152090f99c1d19d44e01aea5a4':
|
|
63
|
+
'https://wax.greymass.com',
|
|
64
|
+
},
|
|
65
|
+
}
|
|
51
66
|
|
|
52
|
-
export
|
|
53
|
-
readonly allowFees: boolean =
|
|
67
|
+
export class TransactPluginResourceProvider extends AbstractTransactPlugin {
|
|
68
|
+
readonly allowFees: boolean = true
|
|
54
69
|
// readonly allowActions: Name[] = [
|
|
55
70
|
// Name.from('eosio.token:transfer'),
|
|
56
71
|
// Name.from('eosio:buyrambytes'),
|
|
57
72
|
// ]
|
|
58
73
|
readonly maxFee?: Asset
|
|
59
74
|
|
|
60
|
-
readonly endpoints: Record<string, string> =
|
|
75
|
+
readonly endpoints: Record<string, string> = defaultOptions.endpoints
|
|
61
76
|
|
|
62
|
-
constructor(options
|
|
77
|
+
constructor(options?: ResourceProviderOptions) {
|
|
63
78
|
super()
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
if (options) {
|
|
80
|
+
// Set the endpoints and chains available
|
|
81
|
+
if (options.endpoints) {
|
|
82
|
+
this.endpoints = options.endpoints
|
|
83
|
+
}
|
|
84
|
+
if (typeof options.allowFees !== 'undefined') {
|
|
85
|
+
this.allowFees = options.allowFees
|
|
86
|
+
}
|
|
87
|
+
if (typeof options.maxFee !== 'undefined') {
|
|
88
|
+
this.maxFee = Asset.from(options.maxFee)
|
|
89
|
+
}
|
|
90
|
+
// TODO: Allow contact/action combos to be passed in and checked against to ensure no rogue actions were appended.
|
|
91
|
+
// if (typeof options.allowActions !== 'undefined') {
|
|
92
|
+
// this.allowActions = options.allowActions.map((action) => Name.from(action))
|
|
93
|
+
// }
|
|
75
94
|
}
|
|
76
95
|
}
|
|
77
96
|
|
|
78
97
|
register(context: TransactContext): void {
|
|
79
|
-
context.addHook(
|
|
80
|
-
|
|
98
|
+
context.addHook(
|
|
99
|
+
TransactHookTypes.beforeSign,
|
|
100
|
+
async (
|
|
101
|
+
request: SigningRequest,
|
|
102
|
+
context: TransactContext
|
|
103
|
+
): Promise<TransactHookResponse> => {
|
|
104
|
+
return this.request(request, context)
|
|
105
|
+
}
|
|
81
106
|
)
|
|
82
107
|
}
|
|
83
108
|
|
|
@@ -127,8 +152,12 @@ export default class ResourceProviderPlugin extends AbstractTransactPlugin {
|
|
|
127
152
|
if (requiresPayment) {
|
|
128
153
|
// If the resource provider offered transaction with a fee, but plugin doesn't allow fees, return the original transaction.
|
|
129
154
|
if (!this.allowFees) {
|
|
130
|
-
// TODO: Notify the script somehow of this, maybe we need an optional logger?
|
|
131
155
|
// Notify that a fee was required but not allowed via allowFees: false.
|
|
156
|
+
if (context.ui) {
|
|
157
|
+
context.ui.status(
|
|
158
|
+
'Resource provider rejected transaction, fee required to proceed and the application disallowed fees.'
|
|
159
|
+
)
|
|
160
|
+
}
|
|
132
161
|
return {
|
|
133
162
|
request,
|
|
134
163
|
}
|
|
@@ -144,8 +173,10 @@ export default class ResourceProviderPlugin extends AbstractTransactPlugin {
|
|
|
144
173
|
)
|
|
145
174
|
|
|
146
175
|
if (!originalActionsIntact) {
|
|
147
|
-
// TODO: Notify the script somehow of this, maybe we need an optional logger?
|
|
148
176
|
// Notify that the original actions requested were modified somehow, and reject the modification.
|
|
177
|
+
if (context.ui) {
|
|
178
|
+
context.ui.status('Resource provider rejected transaction, it was modified.')
|
|
179
|
+
}
|
|
149
180
|
return {
|
|
150
181
|
request,
|
|
151
182
|
}
|
|
@@ -177,8 +208,12 @@ export default class ResourceProviderPlugin extends AbstractTransactPlugin {
|
|
|
177
208
|
// If the resource provider offered transaction with a fee, but the fee was higher than allowed, return the original transaction.
|
|
178
209
|
if (this.maxFee) {
|
|
179
210
|
if (addedFees.units > this.maxFee.units) {
|
|
180
|
-
// TODO: Notify the script somehow of this, maybe we need an optional logger?
|
|
181
211
|
// Notify that a fee was required but higher than allowed via maxFee.
|
|
212
|
+
if (context.ui) {
|
|
213
|
+
context.ui.status(
|
|
214
|
+
'Resource provider rejected transaction, the fee amount was an unusually high amount.'
|
|
215
|
+
)
|
|
216
|
+
}
|
|
182
217
|
return {
|
|
183
218
|
request,
|
|
184
219
|
}
|
|
@@ -188,34 +223,64 @@ export default class ResourceProviderPlugin extends AbstractTransactPlugin {
|
|
|
188
223
|
// Validate that the response is valid for the session.
|
|
189
224
|
await this.validateResponseData(json)
|
|
190
225
|
|
|
191
|
-
//
|
|
192
|
-
|
|
193
|
-
/* Psuedo-code for fee based prompting
|
|
194
|
-
|
|
195
|
-
if (response.status === 402) {
|
|
226
|
+
// Create a new signing request based on the response to return to the session's transact flow.
|
|
227
|
+
const modified = await this.createRequest(json, context)
|
|
196
228
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
229
|
+
if (context.ui && addedFees.value > 0) {
|
|
230
|
+
// Initiate a new cancelable prompt to inform the user of the fee required
|
|
231
|
+
const prompt: Cancelable<PromptResponse> = context.ui.prompt({
|
|
232
|
+
title: 'Fee Required',
|
|
233
|
+
body: 'Resources are required to complete this transaction. Accept fee?',
|
|
234
|
+
elements: [
|
|
235
|
+
{
|
|
236
|
+
type: 'asset',
|
|
237
|
+
data: {
|
|
238
|
+
label: 'Fee required',
|
|
239
|
+
value: addedFees,
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
type: 'accept',
|
|
244
|
+
},
|
|
245
|
+
],
|
|
201
246
|
})
|
|
202
247
|
|
|
203
|
-
//
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
248
|
+
// TODO: Set the timer to match the expiration of the transaction
|
|
249
|
+
const timer = setTimeout(() => {
|
|
250
|
+
prompt.cancel('canceled automatically through timeout')
|
|
251
|
+
}, 120000)
|
|
252
|
+
|
|
253
|
+
// Return the promise from the prompt
|
|
254
|
+
return prompt
|
|
255
|
+
.then(async () => {
|
|
256
|
+
// Return the modified transaction and additional signatures
|
|
257
|
+
return new Promise((r) =>
|
|
258
|
+
r({
|
|
259
|
+
request: modified,
|
|
260
|
+
signatures: json.data.signatures.map((sig) => Signature.from(sig)),
|
|
261
|
+
})
|
|
262
|
+
) as Promise<TransactHookResponse>
|
|
263
|
+
})
|
|
264
|
+
.catch((e) => {
|
|
265
|
+
// Throw if what we caught was a cancelation
|
|
266
|
+
if (e instanceof Canceled) {
|
|
267
|
+
throw e
|
|
268
|
+
}
|
|
269
|
+
// Otherwise if it wasn't a cancel, it was a reject, and continue without modification
|
|
270
|
+
return new Promise((r) => r({request})) as Promise<TransactHookResponse>
|
|
271
|
+
})
|
|
272
|
+
.finally(() => {
|
|
273
|
+
clearTimeout(timer) // TODO: Remove this, it's just here for testing
|
|
274
|
+
})
|
|
275
|
+
}
|
|
213
276
|
|
|
214
277
|
// Return the modified transaction and additional signatures
|
|
215
|
-
return
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
278
|
+
return new Promise((r) =>
|
|
279
|
+
r({
|
|
280
|
+
request: modified,
|
|
281
|
+
signatures: json.data.signatures.map((sig) => Signature.from(sig)),
|
|
282
|
+
})
|
|
283
|
+
)
|
|
219
284
|
}
|
|
220
285
|
|
|
221
286
|
getModifiedTransaction(json): Transaction {
|
|
@@ -235,10 +300,7 @@ export default class ResourceProviderPlugin extends AbstractTransactPlugin {
|
|
|
235
300
|
context: TransactContext
|
|
236
301
|
): Promise<SigningRequest> {
|
|
237
302
|
// Create a new signing request based on the response to return to the session's transact flow.
|
|
238
|
-
const request = await
|
|
239
|
-
{transaction: response.data.request[1]},
|
|
240
|
-
context.esrOptions
|
|
241
|
-
)
|
|
303
|
+
const request = await context.createRequest(response.data.request[1])
|
|
242
304
|
|
|
243
305
|
// Set the required fee onto the request itself for wallets to process.
|
|
244
306
|
if (response.code === 402 && response.data.fee) {
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @wharfkit/resource-provider-plugin v0.2.0
|
|
3
|
-
* https://github.com/wharfkit/resource-provider-plugin
|
|
4
|
-
*
|
|
5
|
-
* @license
|
|
6
|
-
* Copyright (c) 2021 FFF00 Agents AB & Greymass Inc. All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* Redistribution and use in source and binary forms, with or without modification,
|
|
9
|
-
* are permitted provided that the following conditions are met:
|
|
10
|
-
*
|
|
11
|
-
* 1. Redistribution of source code must retain the above copyright notice, this
|
|
12
|
-
* list of conditions and the following disclaimer.
|
|
13
|
-
*
|
|
14
|
-
* 2. Redistribution in binary form must reproduce the above copyright notice,
|
|
15
|
-
* this list of conditions and the following disclaimer in the documentation
|
|
16
|
-
* and/or other materials provided with the distribution.
|
|
17
|
-
*
|
|
18
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
19
|
-
* may be used to endorse or promote products derived from this software without
|
|
20
|
-
* specific prior written permission.
|
|
21
|
-
*
|
|
22
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
23
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
24
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
25
|
-
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
26
|
-
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
27
|
-
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
28
|
-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
29
|
-
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
30
|
-
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
31
|
-
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32
|
-
*
|
|
33
|
-
* YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT DESIGNED, LICENSED OR INTENDED FOR USE
|
|
34
|
-
* IN THE DESIGN, CONSTRUCTION, OPERATION OR MAINTENANCE OF ANY MILITARY FACILITY.
|
|
35
|
-
*/
|
|
36
|
-
import { Struct, Name, Asset, AbstractTransactPlugin, TransactContext, ChainDefinition, SigningRequest, TransactHookResponse, Transaction, AssetType } from '@wharfkit/session';
|
|
37
|
-
|
|
38
|
-
interface ResourceProviderOptions {
|
|
39
|
-
allowFees?: boolean;
|
|
40
|
-
endpoints: Record<string, string>;
|
|
41
|
-
maxFee?: AssetType;
|
|
42
|
-
}
|
|
43
|
-
interface ResourceProviderResponseData {
|
|
44
|
-
request: [string, object];
|
|
45
|
-
signatures: string[];
|
|
46
|
-
version: unknown;
|
|
47
|
-
fee?: AssetType;
|
|
48
|
-
costs?: {
|
|
49
|
-
cpu: AssetType;
|
|
50
|
-
net: AssetType;
|
|
51
|
-
ram: AssetType;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
interface ResourceProviderResponse {
|
|
55
|
-
code: number;
|
|
56
|
-
data: ResourceProviderResponseData;
|
|
57
|
-
}
|
|
58
|
-
declare class Transfer extends Struct {
|
|
59
|
-
from: Name;
|
|
60
|
-
to: Name;
|
|
61
|
-
quantity: Asset;
|
|
62
|
-
memo: string;
|
|
63
|
-
}
|
|
64
|
-
declare class ResourceProviderPlugin extends AbstractTransactPlugin {
|
|
65
|
-
readonly allowFees: boolean;
|
|
66
|
-
readonly maxFee?: Asset;
|
|
67
|
-
readonly endpoints: Record<string, string>;
|
|
68
|
-
constructor(options: ResourceProviderOptions);
|
|
69
|
-
register(context: TransactContext): void;
|
|
70
|
-
getEndpoint(chain: ChainDefinition): string;
|
|
71
|
-
request(request: SigningRequest, context: TransactContext): Promise<TransactHookResponse>;
|
|
72
|
-
getModifiedTransaction(json: any): Transaction;
|
|
73
|
-
createRequest(response: ResourceProviderResponse, context: TransactContext): Promise<SigningRequest>;
|
|
74
|
-
/**
|
|
75
|
-
* Perform validation against the request to ensure it is valid for the resource provider.
|
|
76
|
-
*/
|
|
77
|
-
validateRequest(request: SigningRequest, context: TransactContext): void;
|
|
78
|
-
/**
|
|
79
|
-
* Perform validation against the response to ensure it is valid for the session.
|
|
80
|
-
*/
|
|
81
|
-
validateResponseData(response: Record<string, any>): Promise<void>;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export { Transfer, ResourceProviderPlugin as default };
|