@wharfkit/transact-plugin-resource-provider 0.3.0-ui-5
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/LICENSE +29 -0
- package/README.md +33 -0
- package/lib/resource-provider-plugin.d.ts +84 -0
- package/lib/resource-provider-plugin.js +322 -0
- package/lib/resource-provider-plugin.js.map +1 -0
- package/lib/resource-provider-plugin.m.js +302 -0
- package/lib/resource-provider-plugin.m.js.map +1 -0
- package/lib/resource-provider-plugin.umd.js +303 -0
- package/lib/transact-plugin-resource-provider.d.ts +84 -0
- package/lib/transact-plugin-resource-provider.js +322 -0
- package/lib/transact-plugin-resource-provider.js.map +1 -0
- package/lib/transact-plugin-resource-provider.m.js +302 -0
- package/lib/transact-plugin-resource-provider.m.js.map +1 -0
- package/package.json +60 -0
- package/src/index.ts +289 -0
- package/src/utils.ts +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Copyright (c) 2021 FFF00 Agents AB & Greymass Inc. All Rights Reserved.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
4
|
+
are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
1. Redistribution of source code must retain the above copyright notice, this
|
|
7
|
+
list of conditions and the following disclaimer.
|
|
8
|
+
|
|
9
|
+
2. Redistribution in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
and/or other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
+
may be used to endorse or promote products derived from this software without
|
|
15
|
+
specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
20
|
+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
21
|
+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
22
|
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
23
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
25
|
+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
26
|
+
OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT DESIGNED, LICENSED OR INTENDED FOR USE
|
|
29
|
+
IN THE DESIGN, CONSTRUCTION, OPERATION OR MAINTENANCE OF ANY MILITARY FACILITY.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @wharfkit/transact-plugin-resource-provider
|
|
2
|
+
|
|
3
|
+
A `transactPlugin` for use with the `@wharfkit/session` library that provides resources to perform transactions.
|
|
4
|
+
|
|
5
|
+
## Caveats
|
|
6
|
+
|
|
7
|
+
- Resource Provider API endpoint must conform to the Resource Provider API specification.
|
|
8
|
+
- To enable fees, the `allowFees` parameter must be specified and set to `true`.
|
|
9
|
+
- Any fees must be paid in the networks system token, deployed on the `eosio.token` account using the standard token contract.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
The `@wharfkit/transact-plugin-resource-provider` package is distributed as a module on [npm](https://www.npmjs.com/package/@wharfkit/transact-plugin-resource-provider).
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
yarn add @wharfkit/transact-plugin-resource-provider
|
|
17
|
+
# or
|
|
18
|
+
npm install --save @wharfkit/transact-plugin-resource-provider
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
TODO
|
|
24
|
+
|
|
25
|
+
## Developing
|
|
26
|
+
|
|
27
|
+
You need [Make](https://www.gnu.org/software/make/), [node.js](https://nodejs.org/en/) and [yarn](https://classic.yarnpkg.com/en/docs/install) installed.
|
|
28
|
+
|
|
29
|
+
Clone the repository and run `make` to checkout all dependencies and build the project. See the [Makefile](./Makefile) for other useful targets. Before submitting a pull request make sure to run `make lint`.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
Made with ☕️ & ❤️ by [Greymass](https://greymass.com), if you find this useful please consider [supporting us](https://greymass.com/support-us).
|
|
@@ -0,0 +1,84 @@
|
|
|
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 };
|
|
@@ -0,0 +1,322 @@
|
|
|
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
|
+
'use strict';
|
|
37
|
+
|
|
38
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
39
|
+
|
|
40
|
+
var session = require('@wharfkit/session');
|
|
41
|
+
|
|
42
|
+
/******************************************************************************
|
|
43
|
+
Copyright (c) Microsoft Corporation.
|
|
44
|
+
|
|
45
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
46
|
+
purpose with or without fee is hereby granted.
|
|
47
|
+
|
|
48
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
49
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
50
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
51
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
52
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
53
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
54
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
55
|
+
***************************************************************************** */
|
|
56
|
+
|
|
57
|
+
function __decorate(decorators, target, key, desc) {
|
|
58
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
59
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
60
|
+
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;
|
|
61
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
65
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
66
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
67
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
68
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
69
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
70
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function hasOriginalActions(original, modified) {
|
|
75
|
+
return original.actions.every((originalAction) => {
|
|
76
|
+
return modified.actions.some((modifiedAction) => {
|
|
77
|
+
// Ensure the original contract account matches
|
|
78
|
+
const matchesOriginalContractAccount = originalAction.account.equals(modifiedAction.account);
|
|
79
|
+
// Ensure the original contract action matches
|
|
80
|
+
const matchesOriginalContractAction = originalAction.name.equals(modifiedAction.name);
|
|
81
|
+
// Ensure the original authorization is in tact
|
|
82
|
+
const matchesOriginalAuthorization = originalAction.authorization.length === modifiedAction.authorization.length &&
|
|
83
|
+
originalAction.authorization[0].actor.equals(modifiedAction.authorization[0].actor);
|
|
84
|
+
// Ensure the original action data matches
|
|
85
|
+
const matchesOriginalActionData = originalAction.data.equals(modifiedAction.data);
|
|
86
|
+
// Return any action that does not match the original
|
|
87
|
+
return (matchesOriginalContractAccount &&
|
|
88
|
+
matchesOriginalContractAction &&
|
|
89
|
+
matchesOriginalAuthorization &&
|
|
90
|
+
matchesOriginalActionData);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function getNewActions(original, modified) {
|
|
95
|
+
return modified.actions.filter((modifiedAction) => {
|
|
96
|
+
return original.actions.some((originalAction) => {
|
|
97
|
+
// Ensure the original contract account matches
|
|
98
|
+
const matchesOriginalContractAccount = originalAction.account.equals(modifiedAction.account);
|
|
99
|
+
// Ensure the original contract action matches
|
|
100
|
+
const matchesOriginalContractAction = originalAction.name.equals(modifiedAction.name);
|
|
101
|
+
// Ensure the original authorization is in tact
|
|
102
|
+
const matchesOriginalAuthorization = originalAction.authorization.length === modifiedAction.authorization.length &&
|
|
103
|
+
originalAction.authorization[0].actor.equals(modifiedAction.authorization[0].actor);
|
|
104
|
+
// Ensure the original action data matches
|
|
105
|
+
const matchesOriginalActionData = originalAction.data.equals(modifiedAction.data);
|
|
106
|
+
// Return any action that does not match the original
|
|
107
|
+
return !(matchesOriginalContractAccount &&
|
|
108
|
+
matchesOriginalContractAction &&
|
|
109
|
+
matchesOriginalAuthorization &&
|
|
110
|
+
matchesOriginalActionData);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
exports.Transfer = class Transfer extends session.Struct {
|
|
116
|
+
};
|
|
117
|
+
__decorate([
|
|
118
|
+
session.Struct.field(session.Name)
|
|
119
|
+
], exports.Transfer.prototype, "from", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
session.Struct.field(session.Name)
|
|
122
|
+
], exports.Transfer.prototype, "to", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
session.Struct.field(session.Asset)
|
|
125
|
+
], exports.Transfer.prototype, "quantity", void 0);
|
|
126
|
+
__decorate([
|
|
127
|
+
session.Struct.field('string')
|
|
128
|
+
], exports.Transfer.prototype, "memo", void 0);
|
|
129
|
+
exports.Transfer = __decorate([
|
|
130
|
+
session.Struct.type('transfer')
|
|
131
|
+
], exports.Transfer);
|
|
132
|
+
class ResourceProviderPlugin extends session.AbstractTransactPlugin {
|
|
133
|
+
constructor(options) {
|
|
134
|
+
super();
|
|
135
|
+
this.allowFees = false;
|
|
136
|
+
this.endpoints = {};
|
|
137
|
+
// Set the endpoints and chains available
|
|
138
|
+
this.endpoints = options.endpoints;
|
|
139
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.allowFees) !== 'undefined') {
|
|
140
|
+
this.allowFees = options.allowFees;
|
|
141
|
+
}
|
|
142
|
+
// TODO: Allow contact/action combos to be passed in and checked against to ensure no rogue actions were appended.
|
|
143
|
+
// if (typeof options.allowActions !== 'undefined') {
|
|
144
|
+
// this.allowActions = options.allowActions.map((action) => Name.from(action))
|
|
145
|
+
// }
|
|
146
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.maxFee) !== 'undefined') {
|
|
147
|
+
this.maxFee = session.Asset.from(options.maxFee);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
register(context) {
|
|
151
|
+
context.addHook(session.TransactHookTypes.beforeSign, (request, context) => this.request(request, context));
|
|
152
|
+
}
|
|
153
|
+
getEndpoint(chain) {
|
|
154
|
+
return this.endpoints[String(chain.id)];
|
|
155
|
+
}
|
|
156
|
+
request(request, context) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
// Validate that this request is valid for the resource provider
|
|
159
|
+
this.validateRequest(request, context);
|
|
160
|
+
// Determine appropriate URL for this request
|
|
161
|
+
const endpoint = this.getEndpoint(context.chain);
|
|
162
|
+
// If no endpoint was found, gracefully fail and return the original request.
|
|
163
|
+
if (!endpoint) {
|
|
164
|
+
return {
|
|
165
|
+
request,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
// Assemble the request to the resource provider.
|
|
169
|
+
const url = `${endpoint}/v1/resource_provider/request_transaction`;
|
|
170
|
+
// Perform the request to the resource provider.
|
|
171
|
+
const response = yield context.fetch(url, {
|
|
172
|
+
method: 'POST',
|
|
173
|
+
body: JSON.stringify({
|
|
174
|
+
ref: 'unittest',
|
|
175
|
+
request,
|
|
176
|
+
signer: context.permissionLevel,
|
|
177
|
+
}),
|
|
178
|
+
});
|
|
179
|
+
const json = yield response.json();
|
|
180
|
+
// If the resource provider refused to process this request, return the original request without modification.
|
|
181
|
+
if (response.status === 400) {
|
|
182
|
+
return {
|
|
183
|
+
request,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const requiresPayment = response.status === 402;
|
|
187
|
+
if (requiresPayment) {
|
|
188
|
+
// If the resource provider offered transaction with a fee, but plugin doesn't allow fees, return the original transaction.
|
|
189
|
+
if (!this.allowFees) {
|
|
190
|
+
// TODO: Notify the script somehow of this, maybe we need an optional logger?
|
|
191
|
+
// Notify that a fee was required but not allowed via allowFees: false.
|
|
192
|
+
return {
|
|
193
|
+
request,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Retrieve the transaction from the response
|
|
198
|
+
const modifiedTransaction = this.getModifiedTransaction(json);
|
|
199
|
+
// Ensure the new transaction has an unmodified version of the original action(s)
|
|
200
|
+
const originalActionsIntact = hasOriginalActions(request.getRawTransaction(), modifiedTransaction);
|
|
201
|
+
if (!originalActionsIntact) {
|
|
202
|
+
// TODO: Notify the script somehow of this, maybe we need an optional logger?
|
|
203
|
+
// Notify that the original actions requested were modified somehow, and reject the modification.
|
|
204
|
+
return {
|
|
205
|
+
request,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
// Retrieve all newly appended actions from the modified transaction
|
|
209
|
+
const addedActions = getNewActions(request.getRawTransaction(), modifiedTransaction);
|
|
210
|
+
// TODO: Check that all the addedActions are allowed via this.allowActions
|
|
211
|
+
// Find any transfer actions that were added to the transaction, which we assume are fees
|
|
212
|
+
const addedFees = addedActions
|
|
213
|
+
.filter((action) => action.account.equals('eosio.token') && action.name.equals('transfer'))
|
|
214
|
+
.map((action) => session.Serializer.decode({
|
|
215
|
+
data: action.data,
|
|
216
|
+
type: exports.Transfer,
|
|
217
|
+
}).quantity)
|
|
218
|
+
.reduce((total, fee) => {
|
|
219
|
+
total.units.add(fee.units);
|
|
220
|
+
return total;
|
|
221
|
+
}, session.Asset.from('0.0000 EOS'));
|
|
222
|
+
// If the resource provider offered transaction with a fee, but the fee was higher than allowed, return the original transaction.
|
|
223
|
+
if (this.maxFee) {
|
|
224
|
+
if (addedFees.units > this.maxFee.units) {
|
|
225
|
+
// TODO: Notify the script somehow of this, maybe we need an optional logger?
|
|
226
|
+
// Notify that a fee was required but higher than allowed via maxFee.
|
|
227
|
+
return {
|
|
228
|
+
request,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// Validate that the response is valid for the session.
|
|
233
|
+
yield this.validateResponseData(json);
|
|
234
|
+
// NYI: Interact with interface via context for fee based prompting
|
|
235
|
+
/* Psuedo-code for fee based prompting
|
|
236
|
+
|
|
237
|
+
if (response.status === 402) {
|
|
238
|
+
|
|
239
|
+
// Prompt for the fee acceptance
|
|
240
|
+
const promptResponse = context.userPrompt({
|
|
241
|
+
title: 'Transaction Fee Required',
|
|
242
|
+
message: `This transaction requires a fee of ${response.json.data.fee} EOS. Do you wish to accept this fee?`,
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
// If the user did not accept the fee, return the original request without modification.
|
|
246
|
+
if (!promptResponse) {
|
|
247
|
+
return {
|
|
248
|
+
request,
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
} */
|
|
252
|
+
// Create a new signing request based on the response to return to the session's transact flow.
|
|
253
|
+
const modified = yield this.createRequest(json, context);
|
|
254
|
+
// Return the modified transaction and additional signatures
|
|
255
|
+
return {
|
|
256
|
+
request: modified,
|
|
257
|
+
signatures: json.data.signatures.map((sig) => session.Signature.from(sig)),
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
getModifiedTransaction(json) {
|
|
262
|
+
switch (json.data.request[0]) {
|
|
263
|
+
case 'action':
|
|
264
|
+
throw new Error('A resource provider providing an "action" is not supported.');
|
|
265
|
+
case 'actions':
|
|
266
|
+
throw new Error('A resource provider providing "actions" is not supported.');
|
|
267
|
+
case 'transaction':
|
|
268
|
+
return session.Transaction.from(json.data.request[1]);
|
|
269
|
+
}
|
|
270
|
+
throw new Error('Invalid request type provided by resource provider.');
|
|
271
|
+
}
|
|
272
|
+
createRequest(response, context) {
|
|
273
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
274
|
+
// Create a new signing request based on the response to return to the session's transact flow.
|
|
275
|
+
const request = yield session.SigningRequest.create({ transaction: response.data.request[1] }, context.esrOptions);
|
|
276
|
+
// Set the required fee onto the request itself for wallets to process.
|
|
277
|
+
if (response.code === 402 && response.data.fee) {
|
|
278
|
+
request.setInfoKey('txfee', session.Asset.from(response.data.fee));
|
|
279
|
+
}
|
|
280
|
+
// If the fee costs exist, set them on the request for the signature provider to consume
|
|
281
|
+
if (response.data.costs) {
|
|
282
|
+
request.setInfoKey('txfeecpu', response.data.costs.cpu);
|
|
283
|
+
request.setInfoKey('txfeenet', response.data.costs.net);
|
|
284
|
+
request.setInfoKey('txfeeram', response.data.costs.ram);
|
|
285
|
+
}
|
|
286
|
+
return request;
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Perform validation against the request to ensure it is valid for the resource provider.
|
|
291
|
+
*/
|
|
292
|
+
validateRequest(request, context) {
|
|
293
|
+
// Retrieve first authorizer and ensure it matches session context.
|
|
294
|
+
const firstAction = request.getRawActions()[0];
|
|
295
|
+
const firstAuthorizer = firstAction.authorization[0];
|
|
296
|
+
if (!firstAuthorizer.actor.equals(context.permissionLevel.actor)) {
|
|
297
|
+
throw new Error('The first authorizer of the transaction does not match this session.');
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Perform validation against the response to ensure it is valid for the session.
|
|
302
|
+
*/
|
|
303
|
+
validateResponseData(response) {
|
|
304
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
305
|
+
// If the data wasn't provided in the response, throw an error.
|
|
306
|
+
if (!response) {
|
|
307
|
+
throw new Error('Resource provider did not respond to the request.');
|
|
308
|
+
}
|
|
309
|
+
// If a malformed response with a fee was provided, throw an error.
|
|
310
|
+
if (response.code === 402 && !response.data.fee) {
|
|
311
|
+
throw new Error('Resource provider returned a response indicating required payment, but provided no fee amount.');
|
|
312
|
+
}
|
|
313
|
+
// If no signatures were provided, throw an error.
|
|
314
|
+
if (!response.data.signatures || !response.data.signatures[0]) {
|
|
315
|
+
throw new Error('Resource provider did not return a signature.');
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
exports["default"] = ResourceProviderPlugin;
|
|
322
|
+
//# sourceMappingURL=resource-provider-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-provider-plugin.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":["Transfer","Struct","Name","Asset","AbstractTransactPlugin","TransactHookTypes","Serializer","Signature","Transaction","SigningRequest"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAwCA;AACO,SAAS,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE;AAC1D,IAAI,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;AACjI,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AACnI,SAAS,KAAK,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,C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