@airgap/optimism 0.13.15-beta.12 → 0.13.16-beta.0
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 +7 -6
- package/v1/client/info/OptimismInfoClient.d.ts +2 -0
- package/v1/client/info/OptimismInfoClient.js +3 -0
- package/v1/client/info/OptimismInfoClient.js.map +1 -0
- package/v1/client/node/AirGapNodeClient.d.ts +21 -0
- package/v1/client/node/AirGapNodeClient.js +161 -0
- package/v1/client/node/AirGapNodeClient.js.map +1 -0
- package/v1/client/node/OptimismNodeClient.d.ts +5 -0
- package/v1/client/node/OptimismNodeClient.js +28 -0
- package/v1/client/node/OptimismNodeClient.js.map +1 -0
- package/v1/module/ERC20Tokens.js +82 -1
- package/v1/module/ERC20Tokens.js.map +1 -1
- package/v1/module/OptimismModule.js +3 -2
- package/v1/module/OptimismModule.js.map +1 -1
- package/v1/protocol/OptimismBaseProtocol.d.ts +55 -0
- package/v1/protocol/OptimismBaseProtocol.js +340 -0
- package/v1/protocol/OptimismBaseProtocol.js.map +1 -0
- package/v1/protocol/OptimismProtocol.d.ts +3 -3
- package/v1/protocol/OptimismProtocol.js +21 -16
- package/v1/protocol/OptimismProtocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Token.d.ts +9 -0
- package/v1/protocol/erc20/ERC20Token.js +131 -0
- package/v1/protocol/erc20/ERC20Token.js.map +1 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +37 -4
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-optimism.d.ts +14 -2
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-optimism.json +4 -1
- package/v1/types/crypto.d.ts +2 -0
- package/v1/types/crypto.js +3 -0
- package/v1/types/crypto.js.map +1 -0
- package/v1/types/protocol.d.ts +2 -4
- package/v1/types/transaction.d.ts +8 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airgap/optimism",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.16-beta.0",
|
|
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,12 @@
|
|
|
31
31
|
},
|
|
32
32
|
"author": "Papers AG <contact@papers.ch> (https://papers.ch)",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@airgap/coinlib-core": "
|
|
35
|
-
"@airgap/crypto": "
|
|
36
|
-
"@airgap/ethereum": "
|
|
37
|
-
"@airgap/module-kit": "
|
|
38
|
-
"@airgap/serializer": "
|
|
34
|
+
"@airgap/coinlib-core": "^0.13.16-beta.0",
|
|
35
|
+
"@airgap/crypto": "^0.13.16-beta.0",
|
|
36
|
+
"@airgap/ethereum": "^0.13.16-beta.0",
|
|
37
|
+
"@airgap/module-kit": "^0.13.16-beta.0",
|
|
38
|
+
"@airgap/serializer": "^0.13.16-beta.0",
|
|
39
|
+
"@ethereumjs/tx": "3.4.0"
|
|
39
40
|
},
|
|
40
41
|
"nyc": {
|
|
41
42
|
"include": [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OptimismInfoClient.js","sourceRoot":"","sources":["../../../../src/v1/client/info/OptimismInfoClient.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import BigNumber from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
|
|
2
|
+
import { EthereumUnsignedTransaction } from '@airgap/ethereum/v1';
|
|
3
|
+
import { AirGapTransactionStatus } from '@airgap/module-kit';
|
|
4
|
+
import { OptimismNodeClient } from './OptimismNodeClient';
|
|
5
|
+
export declare class AirGapNodeClient extends OptimismNodeClient {
|
|
6
|
+
private readonly ethereumNodeClient;
|
|
7
|
+
constructor(baseURL: string);
|
|
8
|
+
getL1Fee(contractAddress: string, tx: EthereumUnsignedTransaction): Promise<BigNumber>;
|
|
9
|
+
fetchBalance(address: string): Promise<BigNumber>;
|
|
10
|
+
fetchTransactionCount(address: string): Promise<number>;
|
|
11
|
+
sendSignedTransaction(transaction: string): Promise<string>;
|
|
12
|
+
callBalanceOf(contractAddress: string, address: string): Promise<BigNumber>;
|
|
13
|
+
getTransactionStatus(transactionHash: string): Promise<AirGapTransactionStatus>;
|
|
14
|
+
estimateTransferGas(contractAddress: string, fromAddress: string, toAddress: string, hexAmount: string): Promise<BigNumber>;
|
|
15
|
+
estimateTransactionGas(fromAddress: string, toAddress: string, amount?: string, data?: string, gas?: string): Promise<BigNumber>;
|
|
16
|
+
getGasPrice(): Promise<BigNumber>;
|
|
17
|
+
callBalanceOfOnContracts(contractAddresses: string[], address: string): Promise<{
|
|
18
|
+
[contractAddress: string]: BigNumber;
|
|
19
|
+
}>;
|
|
20
|
+
private send;
|
|
21
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
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
|
+
};
|
|
53
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
+
};
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.AirGapNodeClient = void 0;
|
|
58
|
+
// tslint:disable: max-classes-per-file
|
|
59
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
60
|
+
var axios_0_19_0_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0"));
|
|
61
|
+
var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
62
|
+
var v1_1 = require("@airgap/ethereum/v1");
|
|
63
|
+
var tx_1 = require("@ethereumjs/tx");
|
|
64
|
+
var OptimismNodeClient_1 = require("./OptimismNodeClient");
|
|
65
|
+
var OptimismRPCDataGetL1Fee = /** @class */ (function (_super) {
|
|
66
|
+
__extends(OptimismRPCDataGetL1Fee, _super);
|
|
67
|
+
function OptimismRPCDataGetL1Fee(tx) {
|
|
68
|
+
var _this = _super.call(this, "".concat(OptimismRPCDataGetL1Fee.methodName, "(bytes)")) || this;
|
|
69
|
+
_this.bytes =
|
|
70
|
+
tx.ethereumType === 'raw'
|
|
71
|
+
? tx_1.Transaction.fromTxData({
|
|
72
|
+
nonce: tx.nonce,
|
|
73
|
+
gasLimit: tx.gasLimit,
|
|
74
|
+
gasPrice: tx.gasPrice,
|
|
75
|
+
to: tx.to,
|
|
76
|
+
value: tx.value,
|
|
77
|
+
data: tx.data
|
|
78
|
+
}).serialize()
|
|
79
|
+
: Buffer.from(tx.serialized, 'hex');
|
|
80
|
+
return _this;
|
|
81
|
+
}
|
|
82
|
+
OptimismRPCDataGetL1Fee.prototype.abiEncoded = function () {
|
|
83
|
+
var bytesLength = v1_1.EthereumUtils.toHex(this.bytes.length);
|
|
84
|
+
if (bytesLength.startsWith('0x')) {
|
|
85
|
+
bytesLength = bytesLength.slice(2);
|
|
86
|
+
}
|
|
87
|
+
return _super.prototype.abiEncoded.call(this) + v1_1.EthereumRPCData.addLeadingZeroPadding(bytesLength + this.bytes.toString('hex'), 256);
|
|
88
|
+
};
|
|
89
|
+
OptimismRPCDataGetL1Fee.methodName = 'getL1Fee';
|
|
90
|
+
return OptimismRPCDataGetL1Fee;
|
|
91
|
+
}(v1_1.EthereumRPCData));
|
|
92
|
+
var AirGapNodeClient = /** @class */ (function (_super) {
|
|
93
|
+
__extends(AirGapNodeClient, _super);
|
|
94
|
+
function AirGapNodeClient(baseURL) {
|
|
95
|
+
var _this = _super.call(this, baseURL) || this;
|
|
96
|
+
_this.ethereumNodeClient = new v1_1.AirGapNodeClient(baseURL);
|
|
97
|
+
return _this;
|
|
98
|
+
}
|
|
99
|
+
AirGapNodeClient.prototype.getL1Fee = function (contractAddress, tx) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
var data, body, response, fee;
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
switch (_a.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
data = new OptimismRPCDataGetL1Fee(tx);
|
|
106
|
+
body = new v1_1.EthereumRPCBody('eth_call', [{ to: contractAddress, data: data.abiEncoded() }]);
|
|
107
|
+
return [4 /*yield*/, this.send(body)];
|
|
108
|
+
case 1:
|
|
109
|
+
response = _a.sent();
|
|
110
|
+
fee = new bignumber_1.default(response.result);
|
|
111
|
+
return [2 /*return*/, fee.isNaN() ? new bignumber_1.default(0) : fee];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
AirGapNodeClient.prototype.fetchBalance = function (address) {
|
|
117
|
+
return this.ethereumNodeClient.fetchBalance(address);
|
|
118
|
+
};
|
|
119
|
+
AirGapNodeClient.prototype.fetchTransactionCount = function (address) {
|
|
120
|
+
return this.ethereumNodeClient.fetchTransactionCount(address);
|
|
121
|
+
};
|
|
122
|
+
AirGapNodeClient.prototype.sendSignedTransaction = function (transaction) {
|
|
123
|
+
return this.ethereumNodeClient.sendSignedTransaction(transaction);
|
|
124
|
+
};
|
|
125
|
+
AirGapNodeClient.prototype.callBalanceOf = function (contractAddress, address) {
|
|
126
|
+
return this.ethereumNodeClient.callBalanceOf(contractAddress, address);
|
|
127
|
+
};
|
|
128
|
+
AirGapNodeClient.prototype.getTransactionStatus = function (transactionHash) {
|
|
129
|
+
return this.ethereumNodeClient.getTransactionStatus(transactionHash);
|
|
130
|
+
};
|
|
131
|
+
AirGapNodeClient.prototype.estimateTransferGas = function (contractAddress, fromAddress, toAddress, hexAmount) {
|
|
132
|
+
return this.ethereumNodeClient.estimateTransferGas(contractAddress, fromAddress, toAddress, hexAmount);
|
|
133
|
+
};
|
|
134
|
+
AirGapNodeClient.prototype.estimateTransactionGas = function (fromAddress, toAddress, amount, data, gas) {
|
|
135
|
+
return this.ethereumNodeClient.estimateTransactionGas(fromAddress, toAddress, amount, data, gas);
|
|
136
|
+
};
|
|
137
|
+
AirGapNodeClient.prototype.getGasPrice = function () {
|
|
138
|
+
return this.ethereumNodeClient.getGasPrice();
|
|
139
|
+
};
|
|
140
|
+
AirGapNodeClient.prototype.callBalanceOfOnContracts = function (contractAddresses, address) {
|
|
141
|
+
return this.ethereumNodeClient.callBalanceOfOnContracts(contractAddresses, address);
|
|
142
|
+
};
|
|
143
|
+
AirGapNodeClient.prototype.send = function (body) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
+
var response;
|
|
146
|
+
return __generator(this, function (_a) {
|
|
147
|
+
switch (_a.label) {
|
|
148
|
+
case 0: return [4 /*yield*/, axios_0_19_0_1.default.post(this.baseURL, body.toRPCBody()).catch(function (error) {
|
|
149
|
+
throw new coinlib_core_1.NetworkError(coinlib_core_1.Domain.ETHEREUM, error);
|
|
150
|
+
})];
|
|
151
|
+
case 1:
|
|
152
|
+
response = _a.sent();
|
|
153
|
+
return [2 /*return*/, response.data];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
return AirGapNodeClient;
|
|
159
|
+
}(OptimismNodeClient_1.OptimismNodeClient));
|
|
160
|
+
exports.AirGapNodeClient = AirGapNodeClient;
|
|
161
|
+
//# sourceMappingURL=AirGapNodeClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AirGapNodeClient.js","sourceRoot":"","sources":["../../../../src/v1/client/node/AirGapNodeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,qDAA2D;AAC3D,oGAAsF;AACtF,iHAA0F;AAC1F,0CAQ4B;AAE5B,qCAA4C;AAE5C,2DAAyD;AAEzD;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,EAAE,EAAE,CAAC,QAAQ;oBACrB,EAAE,EAAE,EAAE,CAAC,EAAE;oBACT,KAAK,EAAE,EAAE,CAAC,KAAK;oBACf,IAAI,EAAE,EAAE,CAAC,IAAI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B,EAAE,OAAe;QAC1E,OAAO,IAAI,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;IACrF,CAAC;IAEa,+BAAI,GAAlB,UAAmB,IAAqB;;;;;4BACrB,qBAAM,sBAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,UAAC,KAAK;4BAC5E,MAAM,IAAI,2BAAY,CAAC,qBAAM,CAAC,QAAQ,EAAE,KAAmB,CAAC,CAAA;wBAC9D,CAAC,CAAC,EAAA;;wBAFI,QAAQ,GAAG,SAEf;wBAEF,sBAAO,QAAQ,CAAC,IAAI,EAAA;;;;KACrB;IACH,uBAAC;AAAD,CAAC,AA7DD,CAAsC,uCAAkB,GA6DvD;AA7DY,4CAAgB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import BigNumber from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
|
|
2
|
+
import { EthereumNodeClient, EthereumUnsignedTransaction } from '@airgap/ethereum/v1';
|
|
3
|
+
export declare abstract class OptimismNodeClient extends EthereumNodeClient {
|
|
4
|
+
abstract getL1Fee(contractAddress: string, tx: EthereumUnsignedTransaction): Promise<BigNumber>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.OptimismNodeClient = void 0;
|
|
19
|
+
var v1_1 = require("@airgap/ethereum/v1");
|
|
20
|
+
var OptimismNodeClient = /** @class */ (function (_super) {
|
|
21
|
+
__extends(OptimismNodeClient, _super);
|
|
22
|
+
function OptimismNodeClient() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
return OptimismNodeClient;
|
|
26
|
+
}(v1_1.EthereumNodeClient));
|
|
27
|
+
exports.OptimismNodeClient = OptimismNodeClient;
|
|
28
|
+
//# sourceMappingURL=OptimismNodeClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OptimismNodeClient.js","sourceRoot":"","sources":["../../../../src/v1/client/node/OptimismNodeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,0CAAqF;AAErF;IAAiD,sCAAkB;IAAnE;;IAEA,CAAC;IAAD,yBAAC;AAAD,CAAC,AAFD,CAAiD,uBAAkB,GAElE;AAFqB,gDAAkB"}
|
package/v1/module/ERC20Tokens.js
CHANGED
|
@@ -1,6 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.erc20TokensIdentifiers = exports.erc20Tokens = void 0;
|
|
4
|
-
exports.erc20Tokens = {
|
|
4
|
+
exports.erc20Tokens = {
|
|
5
|
+
'optimism-erc20-op': {
|
|
6
|
+
symbol: 'OP',
|
|
7
|
+
name: 'Optimism',
|
|
8
|
+
marketSymbol: 'op',
|
|
9
|
+
identifier: 'optimism-erc20-op',
|
|
10
|
+
contractAddress: '0x4200000000000000000000000000000000000042',
|
|
11
|
+
decimals: 18
|
|
12
|
+
},
|
|
13
|
+
'optimism-erc20-usdt': {
|
|
14
|
+
symbol: 'USDT',
|
|
15
|
+
name: 'USD Tether (erc20)',
|
|
16
|
+
marketSymbol: 'usdt',
|
|
17
|
+
identifier: 'optimism-erc20-usdt',
|
|
18
|
+
contractAddress: '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58',
|
|
19
|
+
decimals: 6
|
|
20
|
+
},
|
|
21
|
+
'optimism-erc20-usdc': {
|
|
22
|
+
symbol: 'USDC',
|
|
23
|
+
name: 'USD Coin',
|
|
24
|
+
marketSymbol: 'usdc',
|
|
25
|
+
identifier: 'optimism-erc20-usdc',
|
|
26
|
+
contractAddress: '0x7F5c764cBc14f9669B88837ca1490cCa17c31607',
|
|
27
|
+
decimals: 6
|
|
28
|
+
},
|
|
29
|
+
'optimism-erc20-dai': {
|
|
30
|
+
symbol: 'DAI',
|
|
31
|
+
name: 'Dai Stablecoin',
|
|
32
|
+
marketSymbol: 'dai',
|
|
33
|
+
identifier: 'optimism-erc20-dai',
|
|
34
|
+
contractAddress: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
|
|
35
|
+
decimals: 18
|
|
36
|
+
},
|
|
37
|
+
'optimism-erc20-wbtc': {
|
|
38
|
+
symbol: 'WBTC',
|
|
39
|
+
name: 'Wrapped BTC',
|
|
40
|
+
marketSymbol: 'wbtc',
|
|
41
|
+
identifier: 'optimism-erc20-wbtc',
|
|
42
|
+
contractAddress: '0x68f180fcCe6836688e9084f035309E29Bf0A2095',
|
|
43
|
+
decimals: 8
|
|
44
|
+
},
|
|
45
|
+
'optimism-erc20-link': {
|
|
46
|
+
symbol: 'LINK',
|
|
47
|
+
name: 'Chainlink Token',
|
|
48
|
+
marketSymbol: 'link',
|
|
49
|
+
identifier: 'optimism-erc20-link',
|
|
50
|
+
contractAddress: '0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6',
|
|
51
|
+
decimals: 18
|
|
52
|
+
},
|
|
53
|
+
'optimism-erc20-ldo': {
|
|
54
|
+
symbol: 'LDO',
|
|
55
|
+
name: 'Lido DAO Token',
|
|
56
|
+
marketSymbol: 'ldo',
|
|
57
|
+
identifier: 'optimism-erc20-ldo',
|
|
58
|
+
contractAddress: '0xFdb794692724153d1488CcdBE0C56c252596735F',
|
|
59
|
+
decimals: 18
|
|
60
|
+
},
|
|
61
|
+
'optimism-erc20-frax': {
|
|
62
|
+
symbol: 'FRAX',
|
|
63
|
+
name: 'Frax',
|
|
64
|
+
marketSymbol: 'frax',
|
|
65
|
+
identifier: 'optimism-erc20-frax',
|
|
66
|
+
contractAddress: '0x2E3D870790dC77A83DD1d18184Acc7439A53f475',
|
|
67
|
+
decimals: 18
|
|
68
|
+
},
|
|
69
|
+
'optimism-erc20-snx': {
|
|
70
|
+
symbol: 'SNX',
|
|
71
|
+
name: 'Synthetix Network Token',
|
|
72
|
+
marketSymbol: 'snx',
|
|
73
|
+
identifier: 'optimism-erc20-snx',
|
|
74
|
+
contractAddress: '0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4',
|
|
75
|
+
decimals: 18
|
|
76
|
+
},
|
|
77
|
+
'optimism-erc20-ust': {
|
|
78
|
+
symbol: 'UST',
|
|
79
|
+
name: 'TerraUSD',
|
|
80
|
+
marketSymbol: 'ust',
|
|
81
|
+
identifier: 'optimism-erc20-ust',
|
|
82
|
+
contractAddress: '0xFB21B70922B9f6e3C6274BcD6CB1aa8A0fe20B80',
|
|
83
|
+
decimals: 6
|
|
84
|
+
}
|
|
85
|
+
};
|
|
5
86
|
exports.erc20TokensIdentifiers = Object.keys(exports.erc20Tokens);
|
|
6
87
|
//# sourceMappingURL=ERC20Tokens.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ERC20Tokens.js","sourceRoot":"","sources":["../../../src/v1/module/ERC20Tokens.ts"],"names":[],"mappings":";;;AAGa,QAAA,WAAW,GAAuC,EAAE,CAAA;
|
|
1
|
+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E,gBAAgB;QACtB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,oBAAoB;QAChC,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,qBAAqB,EAAE;QACrB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,MAAM;QACZ,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,qBAAqB;QACjC,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,oBAAoB,EAAE;QACpB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,yBAAyB;QAC/B,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,oBAAoB;QAChC,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,oBAAoB,EAAE;QACpB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,UAAU;QAChB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,oBAAoB;QAChC,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,CAAC;KACZ;CACF,CAAA;AAEY,QAAA,sBAAsB,GAAa,MAAM,CAAC,IAAI,CAAC,mBAAW,CAAC,CAAA"}
|
|
@@ -52,6 +52,7 @@ var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
|
52
52
|
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
53
53
|
var v1_1 = require("@airgap/ethereum/v1");
|
|
54
54
|
var module_kit_1 = require("@airgap/module-kit");
|
|
55
|
+
var ERC20Token_1 = require("../protocol/erc20/ERC20Token");
|
|
55
56
|
var OptimismProtocol_1 = require("../protocol/OptimismProtocol");
|
|
56
57
|
var serializer_companion_1 = require("../serializer/v3/serializer-companion");
|
|
57
58
|
var ERC20Tokens_1 = require("./ERC20Tokens");
|
|
@@ -62,7 +63,7 @@ var OptimismModule = /** @class */ (function () {
|
|
|
62
63
|
supportedNetworks: [OptimismProtocol_1.OPTIMISM_MAINNET_PROTOCOL_NETWORK]
|
|
63
64
|
});
|
|
64
65
|
var erc20NetworkRegistry = new module_kit_1.ModuleNetworkRegistry({
|
|
65
|
-
supportedNetworks: [
|
|
66
|
+
supportedNetworks: [ERC20Token_1.OPTIMISM_ERC20_MAINNET_PROTOCOL_NETWORK]
|
|
66
67
|
});
|
|
67
68
|
this.networkRegistries = __assign((_a = {}, _a[coinlib_core_1.MainProtocolSymbols.OPTIMISM] = networkRegistry, _a), ERC20Tokens_1.erc20TokensIdentifiers.reduce(function (obj, next) {
|
|
68
69
|
var _a;
|
|
@@ -114,7 +115,7 @@ var OptimismModule = /** @class */ (function () {
|
|
|
114
115
|
}
|
|
115
116
|
if (ERC20Tokens_1.erc20Tokens[identifier] !== undefined) {
|
|
116
117
|
var tokenMetadata = ERC20Tokens_1.erc20Tokens[identifier];
|
|
117
|
-
return (0,
|
|
118
|
+
return (0, ERC20Token_1.createERC20Token)(tokenMetadata);
|
|
118
119
|
}
|
|
119
120
|
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.OPTIMISM, "Protocol ".concat(identifier, " not supported."));
|
|
120
121
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptimismModule.js","sourceRoot":"","sources":["../../../src/v1/module/OptimismModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAkE;AAClE,sDAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"OptimismModule.js","sourceRoot":"","sources":["../../../src/v1/module/OptimismModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAkE;AAClE,sDAAqE;AACrE,0CAAgF;AAChF,iDAO2B;AAG3B,2DAAwG;AAExG,iEAAwG;AACxG,8EAAqF;AAErF,6CAAmE;AAEnE;IAIE;;QACE,IAAM,eAAe,GAA0B,IAAI,kCAAqB,CAAC;YACvE,iBAAiB,EAAE,CAAC,oDAAiC,CAAC;SACv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EAAA;;;KACpC;IAEY,oDAA2B,GAAxC;;;gBACE,sBAAO,IAAI,oDAA6B,EAAE,EAAA;;;KAC3C;IAEO,uCAAc,GAAtB,UAAuB,UAAkB,EAAE,OAAyB;QAClE,IAAI,UAAU,KAAK,kCAAmB,CAAC,QAAQ,EAAE;YAC/C,OAAO,IAAA,yCAAsB,EAAC,EAAE,OAAO,SAAA,EAAE,CAAC,CAAA;SAC3C;QAED,IAAI,yBAAW,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;YACzC,IAAM,aAAa,GAAuB,yBAAW,CAAC,UAAU,CAAC,CAAA;YAEjE,OAAO,IAAA,6BAAgB,EAAC,aAAa,CAAC,CAAA;SACvC;QAED,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,QAAQ,EAAE,mBAAY,UAAU,oBAAiB,CAAC,CAAA;IAC7F,CAAC;IACH,qBAAC;AAAD,CAAC,AA7DD,IA6DC;AA7DY,wCAAc"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { EthereumBaseProtocolImpl, EthereumUnits } from '@airgap/ethereum/v1';
|
|
2
|
+
import { Address, AirGapProtocol, AirGapTransaction, AirGapTransactionStatus, AirGapTransactionsWithCursor, Amount, Balance, CryptoDerivative, ExtendedKeyPair, ExtendedPublicKey, ExtendedSecretKey, FeeDefaults, KeyPair, ProtocolMetadata, ProtocolUnitsMetadata, PublicKey, SecretKey, Signature, TransactionConfiguration, TransactionDetails } from '@airgap/module-kit';
|
|
3
|
+
import { OptimismInfoClient } from '../client/info/OptimismInfoClient';
|
|
4
|
+
import { OptimismNodeClient } from '../client/node/OptimismNodeClient';
|
|
5
|
+
import { OptimismCryptoConfiguration } from '../types/crypto';
|
|
6
|
+
import { OptimismProtocolNetwork, OptimismProtocolOptions } from '../types/protocol';
|
|
7
|
+
import { OptimismSignedTransaction, OptimismTransactionCursor, OptimismUnsignedTransaction } from '../types/transaction';
|
|
8
|
+
export interface OptimismBaseProtocol<_Units extends string = EthereumUnits> extends AirGapProtocol<{
|
|
9
|
+
AddressResult: Address;
|
|
10
|
+
ProtocolNetwork: OptimismProtocolNetwork;
|
|
11
|
+
CryptoConfiguration: OptimismCryptoConfiguration;
|
|
12
|
+
Units: _Units;
|
|
13
|
+
FeeUnits: EthereumUnits;
|
|
14
|
+
FeeEstimation: FeeDefaults<EthereumUnits>;
|
|
15
|
+
SignedTransaction: OptimismSignedTransaction;
|
|
16
|
+
UnsignedTransaction: OptimismUnsignedTransaction;
|
|
17
|
+
TransactionCursor: OptimismTransactionCursor;
|
|
18
|
+
}, 'Bip32', 'Crypto', 'FetchDataForAddress', 'FetchDataForMultipleAddresses', 'TransactionStatusChecker'> {
|
|
19
|
+
}
|
|
20
|
+
export declare abstract class OptimismBaseProtocolImpl<_Units extends string = EthereumUnits, _EthereumProtocol extends EthereumBaseProtocolImpl<_Units, OptimismProtocolNetwork> = EthereumBaseProtocolImpl<_Units, OptimismProtocolNetwork>> implements OptimismBaseProtocol<_Units> {
|
|
21
|
+
protected readonly ethereumProtocol: _EthereumProtocol;
|
|
22
|
+
protected readonly nodeClient: OptimismNodeClient;
|
|
23
|
+
protected readonly infoClient: OptimismInfoClient;
|
|
24
|
+
protected readonly options: OptimismProtocolOptions;
|
|
25
|
+
protected constructor(ethereumProtocol: _EthereumProtocol, nodeClient: OptimismNodeClient, infoClient: OptimismInfoClient, options: OptimismProtocolOptions);
|
|
26
|
+
protected readonly units: ProtocolUnitsMetadata<_Units>;
|
|
27
|
+
protected readonly feeUnits: ProtocolUnitsMetadata<EthereumUnits>;
|
|
28
|
+
getMetadata(): Promise<ProtocolMetadata<_Units, EthereumUnits>>;
|
|
29
|
+
getAddressFromPublicKey(publicKey: PublicKey | ExtendedPublicKey): Promise<string>;
|
|
30
|
+
deriveFromExtendedPublicKey(extendedPublicKey: ExtendedPublicKey, visibilityIndex: number, addressIndex: number): Promise<PublicKey>;
|
|
31
|
+
getDetailsFromTransaction(transaction: OptimismUnsignedTransaction | OptimismSignedTransaction, publicKey: PublicKey | ExtendedPublicKey): Promise<AirGapTransaction<_Units, EthereumUnits>[]>;
|
|
32
|
+
verifyMessageWithPublicKey(message: string, signature: Signature, publicKey: PublicKey | ExtendedPublicKey): Promise<boolean>;
|
|
33
|
+
encryptAsymmetricWithPublicKey(payload: string, publicKey: PublicKey | ExtendedPublicKey): Promise<string>;
|
|
34
|
+
getCryptoConfiguration(): Promise<OptimismCryptoConfiguration>;
|
|
35
|
+
getKeyPairFromDerivative(derivative: CryptoDerivative): Promise<KeyPair>;
|
|
36
|
+
getExtendedKeyPairFromDerivative(derivative: CryptoDerivative): Promise<ExtendedKeyPair>;
|
|
37
|
+
deriveFromExtendedSecretKey(extendedSecretKey: ExtendedSecretKey, visibilityIndex: number, addressIndex: number): Promise<SecretKey>;
|
|
38
|
+
signTransactionWithSecretKey(transaction: OptimismUnsignedTransaction, secretKey: SecretKey | ExtendedSecretKey): Promise<OptimismSignedTransaction>;
|
|
39
|
+
signMessageWithKeyPair(message: string, keyPair: KeyPair | ExtendedKeyPair): Promise<Signature>;
|
|
40
|
+
decryptAsymmetricWithKeyPair(payload: string, keyPair: KeyPair | ExtendedKeyPair): Promise<string>;
|
|
41
|
+
encryptAESWithSecretKey(payload: string, secretKey: SecretKey | ExtendedSecretKey): Promise<string>;
|
|
42
|
+
decryptAESWithSecretKey(payload: string, secretKey: SecretKey | ExtendedSecretKey): Promise<string>;
|
|
43
|
+
getNetwork(): Promise<OptimismProtocolNetwork>;
|
|
44
|
+
getTransactionsForPublicKey(publicKey: PublicKey | ExtendedPublicKey, limit: number, cursor?: OptimismTransactionCursor): Promise<AirGapTransactionsWithCursor<OptimismTransactionCursor, _Units, EthereumUnits>>;
|
|
45
|
+
getTransactionsForAddress(address: string, limit: number, cursor?: OptimismTransactionCursor): Promise<AirGapTransactionsWithCursor<OptimismTransactionCursor, _Units, EthereumUnits>>;
|
|
46
|
+
getTransactionsForAddresses(addresses: string[], limit: number, cursor?: OptimismTransactionCursor): Promise<AirGapTransactionsWithCursor<OptimismTransactionCursor, _Units, EthereumUnits>>;
|
|
47
|
+
getTransactionStatus(transactionIds: string[]): Promise<Record<string, AirGapTransactionStatus>>;
|
|
48
|
+
getBalanceOfPublicKey(publicKey: PublicKey | ExtendedPublicKey): Promise<Balance<_Units>>;
|
|
49
|
+
getBalanceOfAddress(address: string): Promise<Balance<_Units>>;
|
|
50
|
+
getBalanceOfAddresses(addresses: string[]): Promise<Balance<_Units>>;
|
|
51
|
+
getTransactionMaxAmountWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, to: string[], configuration?: TransactionConfiguration<EthereumUnits>): Promise<Amount<_Units>>;
|
|
52
|
+
getTransactionFeeWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, details: TransactionDetails<_Units>[]): Promise<FeeDefaults<EthereumUnits>>;
|
|
53
|
+
prepareTransactionWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, details: TransactionDetails<_Units>[], configuration?: TransactionConfiguration<EthereumUnits>): Promise<OptimismUnsignedTransaction>;
|
|
54
|
+
broadcastTransaction(transaction: OptimismSignedTransaction): Promise<string>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,340 @@
|
|
|
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
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.OptimismBaseProtocolImpl = void 0;
|
|
54
|
+
var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
55
|
+
var v1_1 = require("@airgap/ethereum/v1");
|
|
56
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
57
|
+
// Implementation
|
|
58
|
+
var OptimismBaseProtocolImpl = /** @class */ (function () {
|
|
59
|
+
function OptimismBaseProtocolImpl(ethereumProtocol, nodeClient, infoClient, options) {
|
|
60
|
+
this.ethereumProtocol = ethereumProtocol;
|
|
61
|
+
this.nodeClient = nodeClient;
|
|
62
|
+
this.infoClient = infoClient;
|
|
63
|
+
this.options = options;
|
|
64
|
+
this.units = this.ethereumProtocol.units;
|
|
65
|
+
this.feeUnits = this.ethereumProtocol.feeUnits;
|
|
66
|
+
}
|
|
67
|
+
OptimismBaseProtocolImpl.prototype.getMetadata = function () {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
return [2 /*return*/, this.ethereumProtocol.getMetadata()];
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
OptimismBaseProtocolImpl.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
return [2 /*return*/, this.ethereumProtocol.getAddressFromPublicKey(publicKey)];
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
OptimismBaseProtocolImpl.prototype.deriveFromExtendedPublicKey = function (extendedPublicKey, visibilityIndex, addressIndex) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
return [2 /*return*/, this.ethereumProtocol.deriveFromExtendedPublicKey(extendedPublicKey, visibilityIndex, addressIndex)];
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
OptimismBaseProtocolImpl.prototype.getDetailsFromTransaction = function (transaction, publicKey) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
var ethereumDetails, l1DataFee, l1DataFeePerTransaction;
|
|
91
|
+
var _this = this;
|
|
92
|
+
return __generator(this, function (_a) {
|
|
93
|
+
switch (_a.label) {
|
|
94
|
+
case 0: return [4 /*yield*/, this.ethereumProtocol.getDetailsFromTransaction(transaction, publicKey)];
|
|
95
|
+
case 1:
|
|
96
|
+
ethereumDetails = _a.sent();
|
|
97
|
+
l1DataFee = transaction.type === 'signed' ? transaction.l1DataFee : transaction.ethereumType === 'raw' ? transaction.l1DataFee : undefined;
|
|
98
|
+
if (l1DataFee === undefined) {
|
|
99
|
+
return [2 /*return*/, ethereumDetails];
|
|
100
|
+
}
|
|
101
|
+
l1DataFeePerTransaction = new bignumber_1.default(l1DataFee).div(ethereumDetails.length);
|
|
102
|
+
return [2 /*return*/, ethereumDetails.map(function (details) {
|
|
103
|
+
var feeBlockchain = (0, module_kit_1.newAmount)(details.fee).blockchain(_this.feeUnits);
|
|
104
|
+
return __assign(__assign({}, details), { fee: (0, module_kit_1.newAmount)(l1DataFeePerTransaction.plus(feeBlockchain.value), 'blockchain') });
|
|
105
|
+
})];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
OptimismBaseProtocolImpl.prototype.verifyMessageWithPublicKey = function (message, signature, publicKey) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
return [2 /*return*/, this.ethereumProtocol.verifyMessageWithPublicKey(message, signature, publicKey)];
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
OptimismBaseProtocolImpl.prototype.encryptAsymmetricWithPublicKey = function (payload, publicKey) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
return [2 /*return*/, this.ethereumProtocol.encryptAsymmetricWithPublicKey(payload, publicKey)];
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
// Offline
|
|
125
|
+
OptimismBaseProtocolImpl.prototype.getCryptoConfiguration = function () {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
return [2 /*return*/, this.ethereumProtocol.getCryptoConfiguration()];
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
OptimismBaseProtocolImpl.prototype.getKeyPairFromDerivative = function (derivative) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
return [2 /*return*/, this.ethereumProtocol.getKeyPairFromDerivative(derivative)];
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
OptimismBaseProtocolImpl.prototype.getExtendedKeyPairFromDerivative = function (derivative) {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
return [2 /*return*/, this.ethereumProtocol.getExtendedKeyPairFromDerivative(derivative)];
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
OptimismBaseProtocolImpl.prototype.deriveFromExtendedSecretKey = function (extendedSecretKey, visibilityIndex, addressIndex) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
return [2 /*return*/, this.ethereumProtocol.deriveFromExtendedSecretKey(extendedSecretKey, visibilityIndex, addressIndex)];
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
OptimismBaseProtocolImpl.prototype.signTransactionWithSecretKey = function (transaction, secretKey) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
155
|
+
var ethereumTransaction;
|
|
156
|
+
return __generator(this, function (_a) {
|
|
157
|
+
switch (_a.label) {
|
|
158
|
+
case 0: return [4 /*yield*/, this.ethereumProtocol.signTransactionWithSecretKey(transaction, secretKey)];
|
|
159
|
+
case 1:
|
|
160
|
+
ethereumTransaction = _a.sent();
|
|
161
|
+
return [2 /*return*/, transaction.ethereumType === 'raw'
|
|
162
|
+
? (0, module_kit_1.newSignedTransaction)(__assign(__assign({}, ethereumTransaction), { l1DataFee: transaction.l1DataFee }))
|
|
163
|
+
: ethereumTransaction];
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
OptimismBaseProtocolImpl.prototype.signMessageWithKeyPair = function (message, keyPair) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
+
return __generator(this, function (_a) {
|
|
171
|
+
return [2 /*return*/, this.ethereumProtocol.signMessageWithKeyPair(message, keyPair)];
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
OptimismBaseProtocolImpl.prototype.decryptAsymmetricWithKeyPair = function (payload, keyPair) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
return [2 /*return*/, this.ethereumProtocol.decryptAsymmetricWithKeyPair(payload, keyPair)];
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
OptimismBaseProtocolImpl.prototype.encryptAESWithSecretKey = function (payload, secretKey) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
+
return __generator(this, function (_a) {
|
|
185
|
+
return [2 /*return*/, this.ethereumProtocol.encryptAESWithSecretKey(payload, secretKey)];
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
OptimismBaseProtocolImpl.prototype.decryptAESWithSecretKey = function (payload, secretKey) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
191
|
+
return __generator(this, function (_a) {
|
|
192
|
+
return [2 /*return*/, this.ethereumProtocol.decryptAESWithSecretKey(payload, secretKey)];
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
// Online
|
|
197
|
+
OptimismBaseProtocolImpl.prototype.getNetwork = function () {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
return __generator(this, function (_a) {
|
|
200
|
+
return [2 /*return*/, this.ethereumProtocol.getNetwork()];
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
OptimismBaseProtocolImpl.prototype.getTransactionsForPublicKey = function (publicKey, limit, cursor) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
+
return __generator(this, function (_a) {
|
|
207
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionsForPublicKey(publicKey, limit, cursor)];
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
OptimismBaseProtocolImpl.prototype.getTransactionsForAddress = function (address, limit, cursor) {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
+
return __generator(this, function (_a) {
|
|
214
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionsForAddress(address, limit, cursor)];
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
OptimismBaseProtocolImpl.prototype.getTransactionsForAddresses = function (addresses, limit, cursor) {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionsForAddresses(addresses, limit, cursor)];
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
OptimismBaseProtocolImpl.prototype.getTransactionStatus = function (transactionIds) {
|
|
226
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
227
|
+
return __generator(this, function (_a) {
|
|
228
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionStatus(transactionIds)];
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
OptimismBaseProtocolImpl.prototype.getBalanceOfPublicKey = function (publicKey) {
|
|
233
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
234
|
+
return __generator(this, function (_a) {
|
|
235
|
+
return [2 /*return*/, this.ethereumProtocol.getBalanceOfPublicKey(publicKey)];
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
OptimismBaseProtocolImpl.prototype.getBalanceOfAddress = function (address) {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
241
|
+
return __generator(this, function (_a) {
|
|
242
|
+
return [2 /*return*/, this.ethereumProtocol.getBalanceOfAddress(address)];
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
OptimismBaseProtocolImpl.prototype.getBalanceOfAddresses = function (addresses) {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
248
|
+
return __generator(this, function (_a) {
|
|
249
|
+
return [2 /*return*/, this.ethereumProtocol.getBalanceOfAddresses(addresses)];
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
OptimismBaseProtocolImpl.prototype.getTransactionMaxAmountWithPublicKey = function (publicKey, to, configuration) {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
255
|
+
var _a, metadata, ethereumMaxAmount, maxAmountBlockchain, maxAmountPerRecipient, ethereumTransaction, l1Fee;
|
|
256
|
+
return __generator(this, function (_b) {
|
|
257
|
+
switch (_b.label) {
|
|
258
|
+
case 0: return [4 /*yield*/, Promise.all([
|
|
259
|
+
this.getMetadata(),
|
|
260
|
+
this.ethereumProtocol.getTransactionMaxAmountWithPublicKey(publicKey, to, configuration)
|
|
261
|
+
])];
|
|
262
|
+
case 1:
|
|
263
|
+
_a = _b.sent(), metadata = _a[0], ethereumMaxAmount = _a[1];
|
|
264
|
+
maxAmountBlockchain = new bignumber_1.default((0, module_kit_1.newAmount)(ethereumMaxAmount).blockchain(metadata.units).value);
|
|
265
|
+
maxAmountPerRecipient = maxAmountBlockchain.div(to.length);
|
|
266
|
+
return [4 /*yield*/, this.ethereumProtocol.prepareTransactionWithPublicKey(publicKey, to.map(function (recipient) { return ({
|
|
267
|
+
to: recipient,
|
|
268
|
+
amount: (0, module_kit_1.newAmount)(maxAmountPerRecipient, 'blockchain')
|
|
269
|
+
}); }), configuration)];
|
|
270
|
+
case 2:
|
|
271
|
+
ethereumTransaction = _b.sent();
|
|
272
|
+
return [4 /*yield*/, this.nodeClient.getL1Fee(this.options.network.gasPriceOracleAddress, ethereumTransaction)];
|
|
273
|
+
case 3:
|
|
274
|
+
l1Fee = _b.sent();
|
|
275
|
+
if (maxAmountBlockchain.lte(l1Fee)) {
|
|
276
|
+
return [2 /*return*/, (0, module_kit_1.newAmount)(0, 'blockchain')];
|
|
277
|
+
}
|
|
278
|
+
return [2 /*return*/, (0, module_kit_1.newAmount)(maxAmountBlockchain.minus(l1Fee), 'blockchain')];
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
OptimismBaseProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (publicKey, details) {
|
|
284
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
+
var l2Fee, ethereumTransaction, l1Fee;
|
|
286
|
+
return __generator(this, function (_a) {
|
|
287
|
+
switch (_a.label) {
|
|
288
|
+
case 0: return [4 /*yield*/, this.ethereumProtocol.getTransactionFeeWithPublicKey(publicKey, details)];
|
|
289
|
+
case 1:
|
|
290
|
+
l2Fee = _a.sent();
|
|
291
|
+
return [4 /*yield*/, this.ethereumProtocol.prepareTransactionWithPublicKey(publicKey, details, { fee: l2Fee.medium })];
|
|
292
|
+
case 2:
|
|
293
|
+
ethereumTransaction = _a.sent();
|
|
294
|
+
return [4 /*yield*/, this.nodeClient.getL1Fee(this.options.network.gasPriceOracleAddress, ethereumTransaction)];
|
|
295
|
+
case 3:
|
|
296
|
+
l1Fee = _a.sent();
|
|
297
|
+
return [2 /*return*/, {
|
|
298
|
+
low: (0, module_kit_1.newAmount)(l1Fee.plus((0, module_kit_1.newAmount)(l2Fee.low).blockchain(this.feeUnits).value), 'blockchain'),
|
|
299
|
+
medium: (0, module_kit_1.newAmount)(l1Fee.plus((0, module_kit_1.newAmount)(l2Fee.medium).blockchain(this.feeUnits).value), 'blockchain'),
|
|
300
|
+
high: (0, module_kit_1.newAmount)(l1Fee.plus((0, module_kit_1.newAmount)(l2Fee.high).blockchain(this.feeUnits).value), 'blockchain')
|
|
301
|
+
}];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
OptimismBaseProtocolImpl.prototype.prepareTransactionWithPublicKey = function (publicKey, details, configuration) {
|
|
307
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
308
|
+
var ethereumTransaction, l1Gas, gasLimit, gasPrice, totalGas, l2Gas, newGasPrice;
|
|
309
|
+
return __generator(this, function (_a) {
|
|
310
|
+
switch (_a.label) {
|
|
311
|
+
case 0: return [4 /*yield*/, this.ethereumProtocol.prepareTransactionWithPublicKey(publicKey, details, configuration)];
|
|
312
|
+
case 1:
|
|
313
|
+
ethereumTransaction = _a.sent();
|
|
314
|
+
if (ethereumTransaction.ethereumType === 'typed') {
|
|
315
|
+
return [2 /*return*/, ethereumTransaction];
|
|
316
|
+
}
|
|
317
|
+
return [4 /*yield*/, this.nodeClient.getL1Fee(this.options.network.gasPriceOracleAddress, ethereumTransaction)];
|
|
318
|
+
case 2:
|
|
319
|
+
l1Gas = _a.sent();
|
|
320
|
+
gasLimit = v1_1.EthereumUtils.hexToNumber(ethereumTransaction.gasLimit);
|
|
321
|
+
gasPrice = v1_1.EthereumUtils.hexToNumber(ethereumTransaction.gasPrice);
|
|
322
|
+
totalGas = gasPrice.times(gasLimit);
|
|
323
|
+
l2Gas = totalGas.minus(l1Gas).abs();
|
|
324
|
+
newGasPrice = l2Gas.div(gasLimit).integerValue(bignumber_1.default.ROUND_CEIL);
|
|
325
|
+
return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)(__assign(__assign({}, ethereumTransaction), { gasPrice: v1_1.EthereumUtils.toHex(newGasPrice.toFixed()), l1DataFee: l1Gas.toFixed() }))];
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
OptimismBaseProtocolImpl.prototype.broadcastTransaction = function (transaction) {
|
|
331
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
332
|
+
return __generator(this, function (_a) {
|
|
333
|
+
return [2 /*return*/, this.ethereumProtocol.broadcastTransaction(transaction)];
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
return OptimismBaseProtocolImpl;
|
|
338
|
+
}());
|
|
339
|
+
exports.OptimismBaseProtocolImpl = OptimismBaseProtocolImpl;
|
|
340
|
+
//# sourceMappingURL=OptimismBaseProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OptimismBaseProtocol.js","sourceRoot":"","sources":["../../../src/v1/protocol/OptimismBaseProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iHAA0F;AAC1F,0CAA4F;AAC5F,iDAwB2B;AAmC3B,iBAAiB;A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CAAC,CAAA;wBAC9C,KAAK,GAAc,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAA;wBAC9C,WAAW,GAAc,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,mBAAS,CAAC,UAAU,CAAC,CAAA;wBAErF,sBAAO,IAAA,mCAAsB,wBACxB,mBAAmB,KACtB,QAAQ,EAAE,kBAAa,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,EACpD,SAAS,EAAE,KAAK,CAAC,OAAO,EAAE,IAC1B,EAAA;;;;KACH;IAEY,uDAAoB,GAAjC,UAAkC,WAAsC;;;gBACtE,sBAAO,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAA;;;KAC/D;IACH,+BAAC;AAAD,CAAC,AA5PD,IA4PC;AA5PqB,4DAAwB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ERC20Protocol } from '@airgap/ethereum/v1';
|
|
2
1
|
import { RecursivePartial } from '@airgap/module-kit';
|
|
3
|
-
import { OptimismProtocolNetwork, OptimismProtocolOptions
|
|
4
|
-
|
|
2
|
+
import { OptimismProtocolNetwork, OptimismProtocolOptions } from '../types/protocol';
|
|
3
|
+
import { OptimismBaseProtocol } from './OptimismBaseProtocol';
|
|
4
|
+
export interface OptimismProtocol extends OptimismBaseProtocol {
|
|
5
5
|
}
|
|
6
6
|
export declare function createOptimismProtocol(options?: RecursivePartial<OptimismProtocolOptions>): OptimismProtocol;
|
|
7
7
|
export declare const OPTIMISM_MAINNET_PROTOCOL_NETWORK: OptimismProtocolNetwork;
|
|
@@ -29,29 +29,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.createOptimismProtocolOptions = exports.OPTIMISM_MAINNET_PROTOCOL_NETWORK = exports.createOptimismProtocol = void 0;
|
|
30
30
|
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
31
31
|
var v1_1 = require("@airgap/ethereum/v1");
|
|
32
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
33
|
+
var AirGapNodeClient_1 = require("../client/node/AirGapNodeClient");
|
|
34
|
+
var OptimismBaseProtocol_1 = require("./OptimismBaseProtocol");
|
|
32
35
|
// Implementation
|
|
33
36
|
var OptimismProtocolImpl = /** @class */ (function (_super) {
|
|
34
37
|
__extends(OptimismProtocolImpl, _super);
|
|
35
38
|
function OptimismProtocolImpl(options) {
|
|
36
39
|
var completeOptions = createOptimismProtocolOptions(options.network);
|
|
37
|
-
var nodeClient = new
|
|
40
|
+
var nodeClient = new AirGapNodeClient_1.AirGapNodeClient(completeOptions.network.rpcUrl);
|
|
38
41
|
var infoClient = new v1_1.EtherscanInfoClient(completeOptions.network.blockExplorerApi, completeOptions.network.blockExplorerApiKey);
|
|
39
|
-
|
|
42
|
+
var baseProtocolOptions = {
|
|
40
43
|
network: completeOptions.network,
|
|
41
|
-
contractAddress: completeOptions.network.contractAddress,
|
|
42
|
-
name: 'Optimism',
|
|
43
44
|
identifier: coinlib_core_1.MainProtocolSymbols.OPTIMISM,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
name: 'Optimism',
|
|
46
|
+
units: v1_1.DEFAULT_ETHEREUM_UNITS_METADATA,
|
|
47
|
+
mainUnit: 'ETH',
|
|
48
|
+
// The layer 2 gas price is normally 0.001 gwei, but it increases when experiencing heavy congestion
|
|
49
|
+
feeDefaults: {
|
|
50
|
+
low: (0, module_kit_1.newAmount)(15.75 /* 21000 GAS * 0.00075 GWEI */, 'GWEI').blockchain(v1_1.DEFAULT_ETHEREUM_UNITS_METADATA),
|
|
51
|
+
medium: (0, module_kit_1.newAmount)(22.05 /* 21000 GAS * 0.00105 GWEI */, 'GWEI').blockchain(v1_1.DEFAULT_ETHEREUM_UNITS_METADATA),
|
|
52
|
+
high: (0, module_kit_1.newAmount)(44.1 /* 21000 GAS * 0.0021 GWEI */, 'GWEI').blockchain(v1_1.DEFAULT_ETHEREUM_UNITS_METADATA)
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var ethereumProtocol = new v1_1.EthereumBaseProtocolImpl(nodeClient, infoClient, baseProtocolOptions);
|
|
56
|
+
return _super.call(this, ethereumProtocol, nodeClient, infoClient, completeOptions) || this;
|
|
52
57
|
}
|
|
53
58
|
return OptimismProtocolImpl;
|
|
54
|
-
}(
|
|
59
|
+
}(OptimismBaseProtocol_1.OptimismBaseProtocolImpl));
|
|
55
60
|
// Factory
|
|
56
61
|
function createOptimismProtocol(options) {
|
|
57
62
|
if (options === void 0) { options = {}; }
|
|
@@ -61,11 +66,11 @@ exports.createOptimismProtocol = createOptimismProtocol;
|
|
|
61
66
|
exports.OPTIMISM_MAINNET_PROTOCOL_NETWORK = {
|
|
62
67
|
name: 'Mainnet',
|
|
63
68
|
type: 'mainnet',
|
|
64
|
-
rpcUrl: 'https://mainnet.
|
|
69
|
+
rpcUrl: 'https://opt-mainnet.g.alchemy.com/v2/fVtiJ6xrTqHg0fvaCYyIfF8S5p_7vnr4',
|
|
65
70
|
chainId: 10,
|
|
66
|
-
contractAddress: '0x4200000000000000000000000000000000000042',
|
|
67
71
|
blockExplorerApi: 'https://api-optimistic.etherscan.io',
|
|
68
|
-
blockExplorerApiKey: 'WQC6EZP3IZU2I1JHVTREI3V3E8K4GYGPN8'
|
|
72
|
+
blockExplorerApiKey: 'WQC6EZP3IZU2I1JHVTREI3V3E8K4GYGPN8',
|
|
73
|
+
gasPriceOracleAddress: '0x420000000000000000000000000000000000000F'
|
|
69
74
|
};
|
|
70
75
|
var DEFAULT_OPTIMISM_PROTOCOL_NETWORK = exports.OPTIMISM_MAINNET_PROTOCOL_NETWORK;
|
|
71
76
|
function createOptimismProtocolOptions(network) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptimismProtocol.js","sourceRoot":"","sources":["../../../src/v1/protocol/OptimismProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA0D;AAC1D,
|
|
1
|
+
{"version":3,"file":"OptimismProtocol.js","sourceRoot":"","sources":["../../../src/v1/protocol/OptimismProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA0D;AAC1D,0CAM4B;AAC5B,iDAAgE;AAEhE,oEAAkE;AAGlE,+DAAuF;AAMvF,iBAAiB;AAEjB;IAAmC,wCAAwB;IACzD,8BAAY,OAAkD;QAC5D,IAAM,eAAe,GAAG,6BAA6B,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAEtE,IAAM,UAAU,GAAG,IAAI,mCAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACvE,IAAM,UAAU,GAAG,IAAI,wBAAmB,CAAC,eAAe,CAAC,OAAO,CAAC,gBAAgB,EAAE,eAAe,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;QAEjI,IAAM,mBAAmB,GAAwE;YAC/F,OAAO,EAAE,eAAe,CAAC,OAAO;YAEhC,UAAU,EAAE,kCAAmB,CAAC,QAAQ;YACxC,IAAI,EAAE,UAAU;YAEhB,KAAK,EAAE,oCAA+B;YACtC,QAAQ,EAAE,KAAK;YAEf,oGAAoG;YACpG,WAAW,EAAE;gBACX,GAAG,EAAE,IAAA,sBAAS,EAAC,KAAK,CAAC,8BAA8B,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,oCAA+B,CAAC;gBACxG,MAAM,EAAE,IAAA,sBAAS,EAAC,KAAK,CAAC,8BAA8B,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,oCAA+B,CAAC;gBAC3G,IAAI,EAAE,IAAA,sBAAS,EAAC,IAAI,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,oCAA+B,CAAC;aACxG;SACF,CAAA;QAED,IAAM,gBAAgB,GAAG,IAAI,6BAAwB,CAAC,UAAU,EAAE,UAAU,EAAE,mBAAmB,CAAC,CAAA;eAElG,kBAAM,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,CAAC;IAClE,CAAC;IACH,2BAAC;AAAD,CAAC,AA5BD,CAAmC,+CAAwB,GA4B1D;AAED,UAAU;AAEV,SAAgB,sBAAsB,CAAC,OAAuD;IAAvD,wBAAA,EAAA,YAAuD;IAC5F,OAAO,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAA;AAC1C,CAAC;AAFD,wDAEC;AAEY,QAAA,iCAAiC,GAA4B;IACxE,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,uEAAuE;IAC/E,OAAO,EAAE,EAAE;IACX,gBAAgB,EAAE,qCAAqC;IACvD,mBAAmB,EAAE,oCAAoC;IACzD,qBAAqB,EAAE,4CAA4C;CACpE,CAAA;AAED,IAAM,iCAAiC,GAA4B,yCAAiC,CAAA;AAEpG,SAAgB,6BAA6B,CAAC,OAA8C;IAA9C,wBAAA,EAAA,YAA8C;IAC1F,OAAO;QACL,OAAO,wBAAO,iCAAiC,GAAK,OAAO,CAAE;KAC9D,CAAA;AACH,CAAC;AAJD,sEAIC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ERC20TokenMetadata, ERC20TokenOptions, EthereumProtocolNetwork } from '@airgap/ethereum/v1';
|
|
2
|
+
import { AirGapInterface, RecursivePartial } from '@airgap/module-kit';
|
|
3
|
+
import { OptimismProtocolNetwork, OptimismProtocolOptions } from '../../types/protocol';
|
|
4
|
+
import { OptimismBaseProtocol } from '../OptimismBaseProtocol';
|
|
5
|
+
export interface ERC20Token extends AirGapInterface<OptimismBaseProtocol<string>, 'SingleTokenSubProtocol'> {
|
|
6
|
+
}
|
|
7
|
+
export declare function createERC20Token(metadata: ERC20TokenMetadata, options?: RecursivePartial<OptimismProtocolOptions>): ERC20Token;
|
|
8
|
+
export declare const OPTIMISM_ERC20_MAINNET_PROTOCOL_NETWORK: OptimismProtocolNetwork;
|
|
9
|
+
export declare function createERC20TokenOptions(metadata: ERC20TokenMetadata, network?: Partial<EthereumProtocolNetwork>): ERC20TokenOptions<OptimismProtocolNetwork>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Factory
|
|
3
|
+
var __extends = (this && this.__extends) || (function () {
|
|
4
|
+
var extendStatics = function (d, b) {
|
|
5
|
+
extendStatics = Object.setPrototypeOf ||
|
|
6
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
+
return extendStatics(d, b);
|
|
9
|
+
};
|
|
10
|
+
return function (d, b) {
|
|
11
|
+
if (typeof b !== "function" && b !== null)
|
|
12
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
+
extendStatics(d, b);
|
|
14
|
+
function __() { this.constructor = d; }
|
|
15
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
var __assign = (this && this.__assign) || function () {
|
|
19
|
+
__assign = Object.assign || function(t) {
|
|
20
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
21
|
+
s = arguments[i];
|
|
22
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
23
|
+
t[p] = s[p];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
return __assign.apply(this, arguments);
|
|
28
|
+
};
|
|
29
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
30
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
31
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
32
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
33
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
34
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
35
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
39
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
40
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
41
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
42
|
+
function step(op) {
|
|
43
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
44
|
+
while (_) try {
|
|
45
|
+
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;
|
|
46
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
47
|
+
switch (op[0]) {
|
|
48
|
+
case 0: case 1: t = op; break;
|
|
49
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
50
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
51
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
52
|
+
default:
|
|
53
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
54
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
55
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
56
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
57
|
+
if (t[2]) _.ops.pop();
|
|
58
|
+
_.trys.pop(); continue;
|
|
59
|
+
}
|
|
60
|
+
op = body.call(thisArg, _);
|
|
61
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
62
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
+
exports.createERC20TokenOptions = exports.OPTIMISM_ERC20_MAINNET_PROTOCOL_NETWORK = exports.createERC20Token = void 0;
|
|
67
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
68
|
+
var v1_1 = require("@airgap/ethereum/v1");
|
|
69
|
+
var AirGapNodeClient_1 = require("../../client/node/AirGapNodeClient");
|
|
70
|
+
var OptimismBaseProtocol_1 = require("../OptimismBaseProtocol");
|
|
71
|
+
var OptimismProtocol_1 = require("../OptimismProtocol");
|
|
72
|
+
// Implementation
|
|
73
|
+
var ERC20TokenImpl = /** @class */ (function (_super) {
|
|
74
|
+
__extends(ERC20TokenImpl, _super);
|
|
75
|
+
function ERC20TokenImpl(options) {
|
|
76
|
+
var nodeClient = new AirGapNodeClient_1.AirGapNodeClient(options.network.rpcUrl);
|
|
77
|
+
var infoClient = new v1_1.EtherscanInfoClient(options.network.blockExplorerApi, options.network.blockExplorerApiKey);
|
|
78
|
+
var ethereumProtocol = new v1_1.ERC20TokenImpl(nodeClient, infoClient, options);
|
|
79
|
+
return _super.call(this, ethereumProtocol, nodeClient, infoClient, options) || this;
|
|
80
|
+
}
|
|
81
|
+
ERC20TokenImpl.prototype.getType = function () {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
return [2 /*return*/, this.ethereumProtocol.getType()];
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
ERC20TokenImpl.prototype.mainProtocol = function () {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
return [2 /*return*/, this.ethereumProtocol.mainProtocol()];
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
ERC20TokenImpl.prototype.getContractAddress = function () {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
return [2 /*return*/, this.ethereumProtocol.getContractAddress()];
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
return ERC20TokenImpl;
|
|
103
|
+
}(OptimismBaseProtocol_1.OptimismBaseProtocolImpl));
|
|
104
|
+
function createERC20Token(metadata, options) {
|
|
105
|
+
if (options === void 0) { options = {}; }
|
|
106
|
+
var completeOptions = createERC20TokenOptions(metadata, options.network);
|
|
107
|
+
return new ERC20TokenImpl(completeOptions);
|
|
108
|
+
}
|
|
109
|
+
exports.createERC20Token = createERC20Token;
|
|
110
|
+
exports.OPTIMISM_ERC20_MAINNET_PROTOCOL_NETWORK = OptimismProtocol_1.OPTIMISM_MAINNET_PROTOCOL_NETWORK;
|
|
111
|
+
var DEFAULT_ERC20_PROTOCOL_NETWORK = exports.OPTIMISM_ERC20_MAINNET_PROTOCOL_NETWORK;
|
|
112
|
+
function createERC20TokenOptions(metadata, network) {
|
|
113
|
+
var _a;
|
|
114
|
+
if (network === void 0) { network = {}; }
|
|
115
|
+
return {
|
|
116
|
+
network: __assign(__assign({}, DEFAULT_ERC20_PROTOCOL_NETWORK), network),
|
|
117
|
+
name: metadata.name,
|
|
118
|
+
identifier: metadata.identifier,
|
|
119
|
+
mainIdentifier: coinlib_core_1.MainProtocolSymbols.OPTIMISM,
|
|
120
|
+
contractAddress: metadata.contractAddress,
|
|
121
|
+
units: (_a = {},
|
|
122
|
+
_a[metadata.symbol] = {
|
|
123
|
+
symbol: { value: metadata.symbol, market: metadata.marketSymbol },
|
|
124
|
+
decimals: metadata.decimals
|
|
125
|
+
},
|
|
126
|
+
_a),
|
|
127
|
+
mainUnit: metadata.symbol
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
exports.createERC20TokenOptions = createERC20TokenOptions;
|
|
131
|
+
//# sourceMappingURL=ERC20Token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ERC20Token.js","sourceRoot":"","sources":["../../../../src/v1/protocol/erc20/ERC20Token.ts"],"names":[],"mappings":";AAAA,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEV,qDAA0D;AAC1D,0CAM4B;AAG5B,uEAAqE;AAErE,gEAAwF;AACxF,wDAAuE;AAMvE,iBAAiB;AAEjB;IAA6B,kCAAiF;IAC5G,wBAAY,OAAmD;QAC7D,IAAM,UAAU,GAAG,IAAI,mCAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAC/D,IAAM,UAAU,GAAG,IAAI,wBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;QAEjH,IAAM,gBAAgB,GAAG,IAAI,mBAAsB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;eAEpF,kBAAM,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC;IAC1D,CAAC;IAEY,gCAAO,GAApB;;;gBACE,sBAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,EAAA;;;KACvC;IAEY,qCAAY,GAAzB;;;gBACE,sBAAO,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,EAAA;;;KAC5C;IAEY,2CAAkB,GAA/B;;;gBACE,sBAAO,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,EAAA;;;KAClD;IACH,qBAAC;AAAD,CAAC,AArBD,CAA6B,+CAAwB,GAqBpD;AAED,SAAgB,gBAAgB,CAAC,QAA4B,EAAE,OAAuD;IAAvD,wBAAA,EAAA,YAAuD;IACpH,IAAM,eAAe,GAAG,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IAE1E,OAAO,IAAI,cAAc,CAAC,eAAe,CAAC,CAAA;AAC5C,CAAC;AAJD,4CAIC;AAEY,QAAA,uCAAuC,GAA4B,oDAAiC,CAAA;AAEjH,IAAM,8BAA8B,GAA4B,+CAAuC,CAAA;AAEvG,SAAgB,uBAAuB,CACrC,QAA4B,EAC5B,OAA8C;;IAA9C,wBAAA,EAAA,YAA8C;IAE9C,OAAO;QACL,OAAO,wBAAO,8BAA8B,GAAK,OAAO,CAAE;QAC1D,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,cAAc,EAAE,kCAAmB,CAAC,QAAQ;QAE5C,eAAe,EAAE,QAAQ,CAAC,eAAe;QAEzC,KAAK;YACH,GAAC,QAAQ,CAAC,MAAM,IAAG;gBACjB,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,YAAY,EAAE;gBACjE,QAAQ,EAAE,QAAQ,CAAC,QAAQ;aAC5B;eACF;QACD,QAAQ,EAAE,QAAQ,CAAC,MAAM;KAC1B,CAAA;AACH,CAAC;AApBD,0DAoBC"}
|
|
@@ -1,21 +1,54 @@
|
|
|
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
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.optimismTransactionSignResponseToSigned = exports.optimismTransactionSignRequestToUnsigned = exports.optimismSignedTransactionToResponse = exports.optimismUnsignedTransactionToRequest = void 0;
|
|
4
15
|
var v1_1 = require("@airgap/ethereum/v1");
|
|
16
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
5
17
|
function optimismUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
|
|
6
|
-
|
|
18
|
+
var ethereumAnyTransactionSignRequest = (0, v1_1.ethereumUnsignedTransactionToRequest)(unsigned, publicKey, callbackUrl);
|
|
19
|
+
if (unsigned.ethereumType === 'raw') {
|
|
20
|
+
var ethereumTransactionSignRequest = ethereumAnyTransactionSignRequest;
|
|
21
|
+
var optimismTransactionSignRequest = __assign(__assign({}, ethereumTransactionSignRequest), { transaction: __assign(__assign({}, ethereumTransactionSignRequest.transaction), { l1DataFee: unsigned.l1DataFee }) });
|
|
22
|
+
return optimismTransactionSignRequest;
|
|
23
|
+
}
|
|
24
|
+
return ethereumAnyTransactionSignRequest;
|
|
7
25
|
}
|
|
8
26
|
exports.optimismUnsignedTransactionToRequest = optimismUnsignedTransactionToRequest;
|
|
9
27
|
function optimismSignedTransactionToResponse(signed, accountIdentifier) {
|
|
10
|
-
return (0, v1_1.ethereumSignedTransactionToResponse)(signed, accountIdentifier);
|
|
28
|
+
return (0, v1_1.ethereumSignedTransactionToResponse)(__assign(__assign({}, signed), { serialized: JSON.stringify({ serialized: signed.serialized, l1DataFee: signed.l1DataFee }) }), accountIdentifier);
|
|
11
29
|
}
|
|
12
30
|
exports.optimismSignedTransactionToResponse = optimismSignedTransactionToResponse;
|
|
13
31
|
function optimismTransactionSignRequestToUnsigned(request) {
|
|
14
|
-
|
|
32
|
+
var ethereumUnsignedTransaction = (0, v1_1.ethereumTransactionSignRequestToUnsigned)(request);
|
|
33
|
+
if (ethereumUnsignedTransaction.ethereumType === 'raw') {
|
|
34
|
+
var optimismRawRequest = request;
|
|
35
|
+
return (0, module_kit_1.newUnsignedTransaction)(__assign(__assign({}, ethereumUnsignedTransaction), { l1DataFee: optimismRawRequest.transaction.l1DataFee }));
|
|
36
|
+
}
|
|
37
|
+
return ethereumUnsignedTransaction;
|
|
15
38
|
}
|
|
16
39
|
exports.optimismTransactionSignRequestToUnsigned = optimismTransactionSignRequestToUnsigned;
|
|
17
40
|
function optimismTransactionSignResponseToSigned(response) {
|
|
18
|
-
|
|
41
|
+
var ethereumSignedTransaction = (0, v1_1.ethereumTransactionSignResponseToSigned)(response);
|
|
42
|
+
try {
|
|
43
|
+
var _a = JSON.parse(ethereumSignedTransaction.serialized), serialized = _a.serialized, l1DataFee = _a.l1DataFee;
|
|
44
|
+
return (0, module_kit_1.newSignedTransaction)({
|
|
45
|
+
serialized: serialized,
|
|
46
|
+
l1DataFee: l1DataFee
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (_b) {
|
|
50
|
+
return ethereumSignedTransaction;
|
|
51
|
+
}
|
|
19
52
|
}
|
|
20
53
|
exports.optimismTransactionSignResponseToSigned = optimismTransactionSignResponseToSigned;
|
|
21
54
|
//# sourceMappingURL=transaction-converter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-converter.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/converter/transaction-converter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transaction-converter.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/converter/transaction-converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,0CAM4B;AAC5B,iDAAiF;AAOjF,SAAgB,oCAAoC,CAClD,QAAqC,EACrC,SAAiB,EACjB,WAAoB;IAEpB,IAAM,iCAAiC,GAAG,IAAA,yCAAoC,EAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;IAEhH,IAAI,QAAQ,CAAC,YAAY,KAAK,KAAK,EAAE;QACnC,IAAM,8BAA8B,GAAG,iCA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|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { TransactionSignRequest } from '@airgap/serializer';
|
|
2
|
+
import { HexString } from '@airgap/serializer/v3/schemas/definitions/hex-string';
|
|
3
|
+
import { OptimismRawUnsignedTransaction } from '../../../../types/transaction';
|
|
4
|
+
export interface SerializableOptimismRawUnsignedTransaction extends Omit<OptimismRawUnsignedTransaction, 'type' | 'ethereumType'> {
|
|
5
|
+
nonce: HexString;
|
|
6
|
+
gasPrice: HexString;
|
|
7
|
+
gasLimit: HexString;
|
|
8
|
+
to: HexString;
|
|
9
|
+
value: HexString;
|
|
10
|
+
chainId: number;
|
|
11
|
+
data: HexString;
|
|
12
|
+
l1DataFee: string;
|
|
13
|
+
}
|
|
14
|
+
export interface OptimismTransactionSignRequest extends TransactionSignRequest<SerializableOptimismRawUnsignedTransaction> {
|
|
3
15
|
}
|
|
@@ -32,6 +32,9 @@
|
|
|
32
32
|
"$ref": "#/definitions/HexString",
|
|
33
33
|
"type": "string"
|
|
34
34
|
},
|
|
35
|
+
"l1DataFee": {
|
|
36
|
+
"type": "string"
|
|
37
|
+
},
|
|
35
38
|
"nonce": {
|
|
36
39
|
"$ref": "#/definitions/HexString",
|
|
37
40
|
"type": "string"
|
|
@@ -45,7 +48,7 @@
|
|
|
45
48
|
"type": "string"
|
|
46
49
|
}
|
|
47
50
|
},
|
|
48
|
-
"required": ["chainId", "data", "gasLimit", "gasPrice", "nonce", "to", "value"],
|
|
51
|
+
"required": ["chainId", "data", "gasLimit", "gasPrice", "l1DataFee", "nonce", "to", "value"],
|
|
49
52
|
"type": "object"
|
|
50
53
|
}
|
|
51
54
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/v1/types/crypto.ts"],"names":[],"mappings":""}
|
package/v1/types/protocol.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { EthereumProtocolNetwork, EthereumProtocolOptions } from '@airgap/ethereum/v1';
|
|
2
|
-
export declare type OptimismUnits = 'OP';
|
|
3
2
|
export interface OptimismProtocolNetwork extends EthereumProtocolNetwork {
|
|
4
|
-
|
|
3
|
+
gasPriceOracleAddress: string;
|
|
5
4
|
}
|
|
6
|
-
export interface OptimismProtocolOptions extends EthereumProtocolOptions {
|
|
7
|
-
network: OptimismProtocolNetwork;
|
|
5
|
+
export interface OptimismProtocolOptions extends EthereumProtocolOptions<OptimismProtocolNetwork> {
|
|
8
6
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { EthereumSignedTransaction,
|
|
2
|
-
export
|
|
1
|
+
import { EthereumRawUnsignedTransaction, EthereumSignedTransaction, EthereumTransactionCursor, EthereumTypedUnsignedTransaction } from '@airgap/ethereum/v1';
|
|
2
|
+
export interface OptimismRawUnsignedTransaction extends EthereumRawUnsignedTransaction {
|
|
3
|
+
l1DataFee: string;
|
|
4
|
+
}
|
|
5
|
+
export declare type OptimismTypedUnsignedTransaction = EthereumTypedUnsignedTransaction;
|
|
6
|
+
export declare type OptimismUnsignedTransaction = OptimismRawUnsignedTransaction | OptimismTypedUnsignedTransaction;
|
|
3
7
|
export interface OptimismSignedTransaction extends EthereumSignedTransaction {
|
|
8
|
+
l1DataFee?: string;
|
|
4
9
|
}
|
|
10
|
+
export declare type OptimismTransactionCursor = EthereumTransactionCursor;
|