@airgap/optimism 0.13.45-beta.3 → 0.13.45-beta.4
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/package.json +6 -6
- package/v1/client/info/OptimismInfoClient.d.ts +1 -1
- package/v1/client/node/HttpOptimismNodeClient.js +90 -24
- package/v1/client/node/HttpOptimismNodeClient.js.map +1 -1
- package/v1/index.js +4 -4
- package/v1/index.js.map +1 -1
- package/v1/module/OptimismModule.js +161 -71
- package/v1/module/OptimismModule.js.map +1 -1
- package/v1/module.js +3 -2
- package/v1/module.js.map +1 -1
- package/v1/protocol/OptimismBaseProtocol.js +352 -154
- package/v1/protocol/OptimismBaseProtocol.js.map +1 -1
- package/v1/protocol/OptimismProtocol.js +54 -27
- package/v1/protocol/OptimismProtocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Token.js +169 -63
- package/v1/protocol/erc20/ERC20Token.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +30 -30
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +152 -73
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +23 -3
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/types/crypto.d.ts +1 -1
- package/v1/types/transaction.d.ts +3 -3
- package/v1/utils/protocol.js +19 -30
- package/v1/utils/protocol.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airgap/optimism",
|
|
3
|
-
"version": "0.13.45-beta.
|
|
3
|
+
"version": "0.13.45-beta.4",
|
|
4
4
|
"description": "The @airgap/optimism is an Optimism implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"airgap",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
},
|
|
32
32
|
"author": "Papers AG <contact@papers.ch> (https://papers.ch)",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@airgap/coinlib-core": "^0.13.45-beta.
|
|
35
|
-
"@airgap/crypto": "^0.13.45-beta.
|
|
36
|
-
"@airgap/ethereum": "^0.13.45-beta.
|
|
37
|
-
"@airgap/module-kit": "^0.13.45-beta.
|
|
38
|
-
"@airgap/serializer": "^0.13.45-beta.
|
|
34
|
+
"@airgap/coinlib-core": "^0.13.45-beta.4",
|
|
35
|
+
"@airgap/crypto": "^0.13.45-beta.4",
|
|
36
|
+
"@airgap/ethereum": "^0.13.45-beta.4",
|
|
37
|
+
"@airgap/module-kit": "^0.13.45-beta.4",
|
|
38
|
+
"@airgap/serializer": "^0.13.45-beta.4",
|
|
39
39
|
"@ethereumjs/tx": "3.4.0"
|
|
40
40
|
},
|
|
41
41
|
"nyc": {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { EthereumInfoClient } from '@airgap/ethereum/v1';
|
|
2
|
-
export type OptimismInfoClient = EthereumInfoClient;
|
|
2
|
+
export declare type OptimismInfoClient = EthereumInfoClient;
|
|
@@ -1,18 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
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;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
2
53
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
54
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
55
|
};
|
|
5
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
57
|
exports.HttpOptimismNodeClient = void 0;
|
|
7
58
|
// tslint:disable: max-classes-per-file
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
59
|
+
var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
60
|
+
var v1_1 = require("@airgap/ethereum/v1");
|
|
61
|
+
var tx_1 = require("@ethereumjs/tx");
|
|
62
|
+
var OptimismRPCDataGetL1Fee = /** @class */ (function (_super) {
|
|
63
|
+
__extends(OptimismRPCDataGetL1Fee, _super);
|
|
64
|
+
function OptimismRPCDataGetL1Fee(tx) {
|
|
65
|
+
var _this = _super.call(this, "".concat(OptimismRPCDataGetL1Fee.methodName, "(bytes)")) || this;
|
|
66
|
+
_this.bytes =
|
|
16
67
|
tx.ethereumType === 'raw'
|
|
17
68
|
? tx_1.Transaction.fromTxData({
|
|
18
69
|
nonce: tx.nonce,
|
|
@@ -23,26 +74,41 @@ class OptimismRPCDataGetL1Fee extends v1_1.EthereumRPCData {
|
|
|
23
74
|
data: tx.data
|
|
24
75
|
}).serialize()
|
|
25
76
|
: Buffer.from(tx.serialized, 'hex');
|
|
77
|
+
return _this;
|
|
26
78
|
}
|
|
27
|
-
abiEncoded() {
|
|
28
|
-
|
|
79
|
+
OptimismRPCDataGetL1Fee.prototype.abiEncoded = function () {
|
|
80
|
+
var bytesLength = v1_1.EthereumUtils.toHex(this.bytes.length);
|
|
29
81
|
if (bytesLength.startsWith('0x')) {
|
|
30
82
|
bytesLength = bytesLength.slice(2);
|
|
31
83
|
}
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const body = new v1_1.EthereumRPCBody('eth_call', [{ to: contractAddress, data: data.abiEncoded() }, v1_1.EthereumRPCBody.blockLatest]);
|
|
42
|
-
const response = await this.send(body);
|
|
43
|
-
const fee = new bignumber_1.default(response.result);
|
|
44
|
-
return fee.isNaN() ? new bignumber_1.default(0) : fee;
|
|
84
|
+
return _super.prototype.abiEncoded.call(this) + v1_1.EthereumRPCData.addLeadingZeroPadding(bytesLength + this.bytes.toString('hex'), 256);
|
|
85
|
+
};
|
|
86
|
+
OptimismRPCDataGetL1Fee.methodName = 'getL1Fee';
|
|
87
|
+
return OptimismRPCDataGetL1Fee;
|
|
88
|
+
}(v1_1.EthereumRPCData));
|
|
89
|
+
var HttpOptimismNodeClient = /** @class */ (function (_super) {
|
|
90
|
+
__extends(HttpOptimismNodeClient, _super);
|
|
91
|
+
function HttpOptimismNodeClient(baseURL, headers) {
|
|
92
|
+
return _super.call(this, baseURL, headers) || this;
|
|
45
93
|
}
|
|
46
|
-
|
|
94
|
+
HttpOptimismNodeClient.prototype.getL1Fee = function (contractAddress, tx) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
var data, body, response, fee;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
data = new OptimismRPCDataGetL1Fee(tx);
|
|
101
|
+
body = new v1_1.EthereumRPCBody('eth_call', [{ to: contractAddress, data: data.abiEncoded() }, v1_1.EthereumRPCBody.blockLatest]);
|
|
102
|
+
return [4 /*yield*/, this.send(body)];
|
|
103
|
+
case 1:
|
|
104
|
+
response = _a.sent();
|
|
105
|
+
fee = new bignumber_1.default(response.result);
|
|
106
|
+
return [2 /*return*/, fee.isNaN() ? new bignumber_1.default(0) : fee];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return HttpOptimismNodeClient;
|
|
112
|
+
}(v1_1.HttpEthereumNodeClient));
|
|
47
113
|
exports.HttpOptimismNodeClient = HttpOptimismNodeClient;
|
|
48
114
|
//# sourceMappingURL=HttpOptimismNodeClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpOptimismNodeClient.js","sourceRoot":"","sources":["../../../../src/v1/client/node/HttpOptimismNodeClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HttpOptimismNodeClient.js","sourceRoot":"","sources":["../../../../src/v1/client/node/HttpOptimismNodeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,iHAA0F;AAC1F,0CAA0I;AAC1I,qCAA4C;AAI5C;IAAsC,2CAAe;IAInD,iCAAY,EAA+B;QAA3C,YACE,kBAAM,UAAG,uBAAuB,CAAC,UAAU,YAAS,CAAC,SAYtD;QAXC,KAAI,CAAC,KAAK;YACR,EAAE,CAAC,YAAY,KAAK,KAAK;gBACvB,CAAC,CAAC,gBAAW,CAAC,UAAU,CAAC;oBACrB,KAAK,EAAE,EAAE,CAAC,KAAK;oBACf,QAAQ,EAAE,EAAE,CAAC,QAAQ;oBACrB,QAAQ,E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AAI,mBAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;wBAE1C,sBAAO,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAA;;;;KAC5C;IACH,6BAAC;AAAD,CAAC,AAdD,CAA4C,2BAAsB,GAcjE;AAdY,wDAAsB"}
|
package/v1/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isOptimismERC20Token = exports.isOptimismProtocol = exports.isAnyOptimismProtocol = exports.createERC20Token = exports.createOptimismProtocol = exports.OptimismModule = void 0;
|
|
4
|
-
|
|
4
|
+
var OptimismModule_1 = require("./module/OptimismModule");
|
|
5
5
|
Object.defineProperty(exports, "OptimismModule", { enumerable: true, get: function () { return OptimismModule_1.OptimismModule; } });
|
|
6
|
-
|
|
6
|
+
var ERC20Token_1 = require("./protocol/erc20/ERC20Token");
|
|
7
7
|
Object.defineProperty(exports, "createERC20Token", { enumerable: true, get: function () { return ERC20Token_1.createERC20Token; } });
|
|
8
|
-
|
|
8
|
+
var OptimismProtocol_1 = require("./protocol/OptimismProtocol");
|
|
9
9
|
Object.defineProperty(exports, "createOptimismProtocol", { enumerable: true, get: function () { return OptimismProtocol_1.createOptimismProtocol; } });
|
|
10
|
-
|
|
10
|
+
var protocol_1 = require("./utils/protocol");
|
|
11
11
|
Object.defineProperty(exports, "isAnyOptimismProtocol", { enumerable: true, get: function () { return protocol_1.isAnyOptimismProtocol; } });
|
|
12
12
|
Object.defineProperty(exports, "isOptimismERC20Token", { enumerable: true, get: function () { return protocol_1.isOptimismERC20Token; } });
|
|
13
13
|
Object.defineProperty(exports, "isOptimismProtocol", { enumerable: true, get: function () { return protocol_1.isOptimismProtocol; } });
|
package/v1/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,0DAAwD;AAgB/C,+FAhBA,+BAAc,OAgBA;AAfvB,0DAA0E;AAmBX,iGAnBtD,6BAAgB,OAmBsD;AAlB/E,gEAAsF;AAkB3D,uGAlBlB,yCAAsB,OAkBkB;AARjD,6CAAkG;AAyBzF,sGAzBA,gCAAqB,OAyBA;AAAsB,qGAzBpB,+BAAoB,OAyBoB;AAAxC,mGAzBsB,6BAAkB,OAyBtB"}
|
|
@@ -1,92 +1,182 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
2
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
50
|
exports.OptimismModule = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
51
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
52
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
53
|
+
var v1_1 = require("@airgap/ethereum/v1");
|
|
54
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
55
|
+
var module_1 = require("../module");
|
|
56
|
+
var ERC20Token_1 = require("../protocol/erc20/ERC20Token");
|
|
57
|
+
var OptimismProtocol_1 = require("../protocol/OptimismProtocol");
|
|
58
|
+
var serializer_companion_1 = require("../serializer/v3/serializer-companion");
|
|
59
|
+
var ERC20Tokens_1 = require("./ERC20Tokens");
|
|
60
|
+
var OptimismModule = /** @class */ (function () {
|
|
61
|
+
function OptimismModule() {
|
|
62
|
+
var _a;
|
|
63
|
+
var networkRegistry = new module_kit_1.ModuleNetworkRegistry({
|
|
16
64
|
supportedNetworks: [OptimismProtocol_1.OPTIMISM_MAINNET_PROTOCOL_NETWORK]
|
|
17
65
|
});
|
|
18
|
-
|
|
66
|
+
var erc20NetworkRegistry = new module_kit_1.ModuleNetworkRegistry({
|
|
19
67
|
supportedNetworks: [ERC20Token_1.OPTIMISM_ERC20_MAINNET_PROTOCOL_NETWORK]
|
|
20
68
|
});
|
|
21
|
-
this.networkRegistries = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
69
|
+
this.networkRegistries = __assign((_a = {}, _a[coinlib_core_1.MainProtocolSymbols.OPTIMISM] = networkRegistry, _a), ERC20Tokens_1.erc20TokensIdentifiers.reduce(function (obj, next) {
|
|
70
|
+
var _a;
|
|
71
|
+
return Object.assign(obj, (_a = {}, _a[next] = erc20NetworkRegistry, _a));
|
|
72
|
+
}, {}));
|
|
25
73
|
this.supportedProtocols = (0, module_kit_1.createSupportedProtocols)(this.networkRegistries);
|
|
26
74
|
}
|
|
27
|
-
|
|
28
|
-
return this
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
75
|
+
OptimismModule.prototype.createOfflineProtocol = function (identifier) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
return [2 /*return*/, this.createProtocol(identifier)];
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
OptimismModule.prototype.createOnlineProtocol = function (identifier, networkOrId) {
|
|
83
|
+
var _a;
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var network;
|
|
86
|
+
return __generator(this, function (_b) {
|
|
87
|
+
network = typeof networkOrId === 'object' ? networkOrId : (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkOrId);
|
|
88
|
+
if (network === undefined) {
|
|
89
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.OPTIMISM, 'Protocol network type not supported.');
|
|
90
|
+
}
|
|
91
|
+
return [2 /*return*/, this.createProtocol(identifier, network)];
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
OptimismModule.prototype.createBlockExplorer = function (identifier, networkOrId) {
|
|
96
|
+
var _a;
|
|
97
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
+
var network;
|
|
99
|
+
return __generator(this, function (_b) {
|
|
100
|
+
network = typeof networkOrId === 'object' ? networkOrId : (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkOrId);
|
|
101
|
+
if (network === undefined) {
|
|
102
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.OPTIMISM, 'Block Explorer network type not supported.');
|
|
103
|
+
}
|
|
104
|
+
return [2 /*return*/, new v1_1.EtherscanBlockExplorer(network.blockExplorerUrl)];
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
OptimismModule.prototype.createV3SerializerCompanion = function () {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
return [2 /*return*/, new serializer_companion_1.OptimismV3SerializerCompanion()];
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
OptimismModule.prototype.createProtocol = function (identifier, network) {
|
|
48
116
|
if (identifier === coinlib_core_1.MainProtocolSymbols.OPTIMISM) {
|
|
49
|
-
return (0, OptimismProtocol_1.createOptimismProtocol)({ network });
|
|
117
|
+
return (0, OptimismProtocol_1.createOptimismProtocol)({ network: network });
|
|
50
118
|
}
|
|
51
119
|
if (ERC20Tokens_1.erc20Tokens[identifier] !== undefined) {
|
|
52
|
-
|
|
120
|
+
var tokenMetadata = ERC20Tokens_1.erc20Tokens[identifier];
|
|
53
121
|
return (0, ERC20Token_1.createERC20Token)(tokenMetadata);
|
|
54
122
|
}
|
|
55
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.OPTIMISM,
|
|
56
|
-
}
|
|
123
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.OPTIMISM, "Protocol ".concat(identifier, " not supported."));
|
|
124
|
+
};
|
|
57
125
|
// ProtocolSerializer
|
|
58
|
-
|
|
59
|
-
return this
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
126
|
+
OptimismModule.prototype.serializeOfflineProtocol = function (protocol) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
return [2 /*return*/, this.serializeProtocol(protocol, 'offline')];
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
OptimismModule.prototype.deserializeOfflineProtocol = function (serialized) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
return [2 /*return*/, this.deserializeProtocol(serialized)];
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
OptimismModule.prototype.serializeOnlineProtocol = function (protocol) {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
142
|
+
return __generator(this, function (_a) {
|
|
143
|
+
return [2 /*return*/, this.serializeProtocol(protocol, 'online')];
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
OptimismModule.prototype.deserializeOnlineProtocol = function (serialized) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
+
return __generator(this, function (_a) {
|
|
150
|
+
return [2 /*return*/, this.deserializeProtocol(serialized)];
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
OptimismModule.prototype.serializeProtocol = function (protocol, type) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
+
var _a, metadata, serializedProtocol;
|
|
157
|
+
return __generator(this, function (_b) {
|
|
158
|
+
switch (_b.label) {
|
|
159
|
+
case 0:
|
|
160
|
+
if (!(0, module_1.isOptimismERC20Token)(protocol)) return [3 /*break*/, 2];
|
|
161
|
+
return [4 /*yield*/, Promise.all([
|
|
162
|
+
protocol.getMetadata(),
|
|
163
|
+
(0, ERC20Token_1.serializeERC20Token)(protocol)
|
|
164
|
+
])];
|
|
165
|
+
case 1:
|
|
166
|
+
_a = _b.sent(), metadata = _a[0], serializedProtocol = _a[1];
|
|
167
|
+
return [2 /*return*/, __assign({ type: type, identifier: metadata.identifier }, serializedProtocol)];
|
|
168
|
+
case 2: return [2 /*return*/, undefined];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
OptimismModule.prototype.deserializeProtocol = function (serialized) {
|
|
85
174
|
if (serialized.identifier.startsWith(coinlib_core_1.SubProtocolSymbols.OPTIMISM_ERC20) && (0, ERC20Token_1.isSerializedERC20Token)(serialized)) {
|
|
86
175
|
return (0, ERC20Token_1.deserializeERC20Token)(serialized);
|
|
87
176
|
}
|
|
88
177
|
return undefined;
|
|
89
|
-
}
|
|
90
|
-
|
|
178
|
+
};
|
|
179
|
+
return OptimismModule;
|
|
180
|
+
}());
|
|
91
181
|
exports.OptimismModule = OptimismModule;
|
|
92
182
|
//# sourceMappingURL=OptimismModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptimismModule.js","sourceRoot":"","sources":["../../../src/v1/module/OptimismModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OptimismModule.js","sourceRoot":"","sources":["../../../src/v1/module/OptimismModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsF;AACtF,sDAAqE;AACrE,0CAAgF;AAChF,iDAgB2B;AAE3B,oCAAgD;AAChD,2DAMqC;AACrC,iEAAwG;AACxG,8EAAqF;AAGrF,6CAAmE;AAEnE;IAIE;;QACE,IAAM,eAAe,GAA0B,IAAI,kCAAqB,CAAC;YACvE,iBAAiB,EAAE,CAAC,oDAAiC,CAAC;SACvD,CAAC,CAAA;QACF,IAAM,oBAAoB,GAA0B,IAAI,kCAAqB,CAAC;YAC5E,iBAAiB,EAAE,CAAC,oDAAuC,CAAC;SAC7D,CA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,EAAE;gCACtB,IAAA,gCAAmB,EAAC,QAAQ,CAAC;6BAC9B,CAAC,EAAA;;wBAHI,KAA0D,SAG9D,EAHK,QAAQ,QAAA,EAAE,kBAAkB,QAAA;wBAKnC,iCACE,IAAI,MAAA,EACJ,UAAU,EAAE,QAAQ,CAAC,UAAU,IAC5B,kBAAkB,GACtB;4BAGH,sBAAO,SAAS,EAAA;;;;KACjB;IAEO,4CAAmB,GAA3B,UAA4B,UAAuC;QACjE,IAAI,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,iCAAkB,CAAC,cAAc,CAAC,IAAI,IAAA,mCAAsB,EAAC,UAAU,CAAC,EAAE;YAC7G,OAAO,IAAA,kCAAqB,EAAC,UAAU,CAAC,CAAA;SACzC;QAED,OAAO,SAAS,CAAA;IAClB,CAAC;IACH,qBAAC;AAAD,CAAC,AA5HD,IA4HC;AA5HY,wCAAc"}
|
package/v1/module.js
CHANGED
|
@@ -14,10 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.create =
|
|
18
|
-
|
|
17
|
+
exports.create = void 0;
|
|
18
|
+
var OptimismModule_1 = require("./module/OptimismModule");
|
|
19
19
|
__exportStar(require("./index"), exports);
|
|
20
20
|
function create() {
|
|
21
21
|
return new OptimismModule_1.OptimismModule();
|
|
22
22
|
}
|
|
23
|
+
exports.create = create;
|
|
23
24
|
//# sourceMappingURL=module.js.map
|
package/v1/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/v1/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/v1/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,0DAAwD;AAExD,0CAAuB;AAEvB,SAAgB,MAAM;IACpB,OAAO,IAAI,+BAAc,EAAE,CAAA;AAC7B,CAAC;AAFD,wBAEC"}
|