@marigold-dev/gas-station-lib
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -38,2 +38,5 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -43,3 +46,3 @@ exports.PermitContract = exports.GasStation = void 0; | ||
var michel_codec_1 = require("@taquito/michel-codec"); | ||
var blake2b = require("blake2b"); | ||
var blake2b_1 = __importDefault(require("blake2b")); | ||
var utils_1 = require("@taquito/utils"); | ||
@@ -57,6 +60,5 @@ var GasStation = /** @class */ (function () { | ||
post_content = { | ||
sender: sender, | ||
operations: ops | ||
sender_address: sender, | ||
operations: ops, | ||
}; | ||
console.log(post_content); | ||
return [4 /*yield*/, fetch(this.url, { | ||
@@ -68,5 +70,5 @@ method: "POST", | ||
headers: { | ||
"Content-Type": "application/json" | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(post_content) | ||
body: JSON.stringify(post_content), | ||
})]; | ||
@@ -101,3 +103,5 @@ case 1: | ||
return [4 /*yield*/, contract.storage()]; | ||
case 2: return [2 /*return*/, (_a.sent()).extension.counter.c[0]]; | ||
case 2: | ||
// @ts-ignore | ||
return [2 /*return*/, (_a.sent()).extension.counter.c[0]]; | ||
} | ||
@@ -108,6 +112,7 @@ }); | ||
PermitContract.prototype.generatePermit = function (transfer) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var rpcClient, chain_id, counter, contract, transfer_type, transfer_data, byts, blak, transfer_hash, permit_data, permit_type, permit_bytes; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
@@ -117,46 +122,36 @@ rpcClient = new rpc_1.RpcClient(this.tezos._rpc, "main"); | ||
case 1: | ||
chain_id = _a.sent(); | ||
chain_id = _b.sent(); | ||
return [4 /*yield*/, this.getCounter()]; | ||
case 2: | ||
counter = _a.sent(); | ||
counter = _b.sent(); | ||
return [4 /*yield*/, this.tezos.wallet.at(this.address)]; | ||
case 3: | ||
contract = _a.sent(); | ||
transfer_type = contract.entrypoints.entrypoints.transfer.args[0]; | ||
transfer_data = contract.methodsObject.transfer([ | ||
transfer | ||
]).toTransferParams().parameter.value[0]; | ||
contract = _b.sent(); | ||
transfer_type = (_a = contract.entrypoints.entrypoints.transfer.args) === null || _a === void 0 ? void 0 : _a[0]; | ||
transfer_data = contract.methodsObject | ||
.transfer([transfer]) | ||
.toTransferParams().parameter.value[0]; | ||
byts = (0, michel_codec_1.packDataBytes)(transfer_data, transfer_type).bytes; | ||
blak = blake2b(32); | ||
transfer_hash = blak.update((0, utils_1.hex2buf)(byts)).digest('hex'); | ||
blak = (0, blake2b_1.default)(32); | ||
transfer_hash = blak.update((0, utils_1.hex2buf)(byts)).digest("hex"); | ||
permit_data = [ | ||
[ | ||
{ "string": chain_id }, | ||
{ "string": this.address } | ||
], | ||
[ | ||
{ "int": counter }, | ||
{ "bytes": transfer_hash } | ||
] | ||
[{ string: chain_id }, { string: this.address }], | ||
[{ int: counter }, { bytes: transfer_hash }], | ||
]; | ||
permit_type = { | ||
'prim': 'pair', | ||
'args': [ | ||
prim: "pair", | ||
args: [ | ||
{ | ||
'prim': 'pair', | ||
'args': [ | ||
{ 'prim': 'chain_id' }, | ||
{ 'prim': 'address' } | ||
] | ||
prim: "pair", | ||
args: [{ prim: "chain_id" }, { prim: "address" }], | ||
}, | ||
{ | ||
'prim': 'pair', | ||
'args': [ | ||
{ 'prim': 'int' }, | ||
{ 'prim': 'bytes' } | ||
] | ||
} | ||
] | ||
prim: "pair", | ||
args: [{ prim: "int" }, { prim: "bytes" }], | ||
}, | ||
], | ||
}; | ||
permit_bytes = (0, michel_codec_1.packDataBytes)(permit_data, permit_type).bytes; | ||
console.info("Permit bytes :", permit_bytes); | ||
console.info("Transfert hash : ", transfer_hash); | ||
return [2 /*return*/, { bytes: permit_bytes, transfer_hash: transfer_hash }]; | ||
@@ -175,9 +170,8 @@ } | ||
contract = _a.sent(); | ||
return [4 /*yield*/, contract.methods.permit([[ | ||
op.publicKey, | ||
op.signature, | ||
op.transferHash | ||
]]).toTransferParams()]; | ||
return [4 /*yield*/, contract.methods | ||
.permit([[op.publicKey, op.signature, op.transferHash]]) | ||
.toTransferParams()]; | ||
case 2: | ||
call = _a.sent(); | ||
console.info("Transfert params", call); | ||
return [2 /*return*/, call]; | ||
@@ -191,1 +185,2 @@ } | ||
exports.PermitContract = PermitContract; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@marigold-dev/gas-station-lib", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Interact with a gas station API and produce TZIP 17 permits", | ||
@@ -11,3 +11,3 @@ "main": "./dist/index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "tsc --outDir dist index.ts && chmod +x ./dist/index.js", | ||
"build": "tsc --outDir dist && chmod +x ./dist/index.js", | ||
"dev": "tsc -w" | ||
@@ -18,5 +18,5 @@ }, | ||
"dependencies": { | ||
"@taquito/michel-codec": "17.3.0", | ||
"@taquito/rpc": "17.3.0", | ||
"@taquito/taquito": "17.3.0", | ||
"@taquito/rpc": "17.3.0", | ||
"@taquito/michel-codec": "17.3.0", | ||
"@taquito/utils": "17.3.0", | ||
@@ -26,3 +26,5 @@ "blake2b": "^2.1.4" | ||
"devDependencies": { | ||
"@types/blake2b": "^2.1.3", | ||
"typescript": "^5.3.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14455
5
216
2
2