@taquito/taquito 23.0.3 → 24.0.0-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/README.md +1 -1
- package/dist/lib/batch/constants.js +16 -0
- package/dist/lib/batch/rpc-batch-provider.js +5 -9
- package/dist/lib/constants.js +5 -32
- package/dist/lib/contract/constants.js +4 -0
- package/dist/lib/contract/contract-methods/contract-method-factory.js +0 -4
- package/dist/lib/contract/contract-methods/contract-method-object-param.js +13 -8
- package/dist/lib/contract/contract.js +9 -32
- package/dist/lib/contract/index.js +0 -1
- package/dist/lib/contract/rpc-contract-provider.js +6 -39
- package/dist/lib/estimate/rpc-estimate-provider.js +6 -6
- package/dist/lib/import-key.js +51 -0
- package/dist/lib/operations/batch-operation.js +2 -2
- package/dist/lib/operations/transfer-ticket-operation.js +1 -1
- package/dist/lib/prepare/prepare-provider.js +6 -6
- package/dist/lib/provider.js +0 -9
- package/dist/lib/subscribe/polling-subcribe-provider.js +3 -3
- package/dist/lib/taquito.js +3 -2
- package/dist/lib/version.js +2 -2
- package/dist/lib/wallet/batch-operation.js +11 -3
- package/dist/lib/wallet/index.js +1 -0
- package/dist/lib/wallet/legacy.js +5 -0
- package/dist/lib/wallet/operation-factory.js +6 -0
- package/dist/lib/wallet/register-global-constant-operation.js +62 -0
- package/dist/lib/wallet/wallet.js +31 -10
- package/dist/taquito.es6.js +3399 -3442
- package/dist/taquito.es6.js.map +1 -1
- package/dist/taquito.min.js +1 -1
- package/dist/taquito.min.js.LICENSE.txt +2 -0
- package/dist/taquito.umd.js +3391 -3437
- package/dist/taquito.umd.js.map +1 -1
- package/dist/types/batch/constants.d.ts +3 -0
- package/dist/types/batch/rpc-batch-provider.d.ts +2 -5
- package/dist/types/constants.d.ts +4 -31
- package/dist/types/contract/constants.d.ts +1 -0
- package/dist/types/contract/contract-methods/contract-method-factory.d.ts +2 -4
- package/dist/types/contract/contract-methods/contract-method-object-param.d.ts +4 -3
- package/dist/types/contract/contract-methods/contract-on-chain-view.d.ts +2 -2
- package/dist/types/contract/contract.d.ts +4 -23
- package/dist/types/contract/index.d.ts +0 -1
- package/dist/types/contract/interface.d.ts +0 -13
- package/dist/types/contract/rpc-contract-provider.d.ts +0 -13
- package/dist/types/estimate/estimate-provider-interface.d.ts +2 -2
- package/dist/types/estimate/rpc-estimate-provider.d.ts +2 -2
- package/dist/types/import-key.d.ts +13 -0
- package/dist/types/operations/transfer-ticket-operation.d.ts +1 -1
- package/dist/types/operations/types.d.ts +7 -2
- package/dist/types/prepare/interface.d.ts +2 -3
- package/dist/types/prepare/prepare-provider.d.ts +1 -2
- package/dist/types/provider.d.ts +1 -6
- package/dist/types/taquito.d.ts +1 -6
- package/dist/types/wallet/batch-operation.d.ts +2 -1
- package/dist/types/wallet/index.d.ts +1 -0
- package/dist/types/wallet/interface.d.ts +7 -2
- package/dist/types/wallet/legacy.d.ts +2 -1
- package/dist/types/wallet/operation-factory.d.ts +2 -0
- package/dist/types/wallet/register-global-constant-operation.d.ts +13 -0
- package/dist/types/wallet/wallet.d.ts +20 -11
- package/package.json +13 -11
- package/dist/400.taquito.min.js +0 -1
- package/dist/993.taquito.min.js +0 -1
- package/dist/lib/contract/contract-methods/contract-method-flat-param.js +0 -92
- package/dist/lib/contract/lambda-view.js +0 -253
- package/dist/types/contract/contract-methods/contract-method-flat-param.d.ts +0 -43
- package/dist/types/contract/lambda-view.d.ts +0 -19
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Context } from '../context';
|
|
2
|
-
import { ContractAbstraction
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { ContractAbstraction } from '../contract/contract';
|
|
3
|
+
import type { ContractStorageType, DefaultWalletType } from '../contract/contract';
|
|
4
|
+
import { SendParams } from '../contract/contract-methods/contract-method-interface';
|
|
5
|
+
import type { ContractMethodObject } from '../contract/contract-methods/contract-method-object-param';
|
|
5
6
|
import { OpKind, withKind } from '../operations/types';
|
|
6
7
|
import { OriginationWalletOperation } from './origination-operation';
|
|
7
|
-
import { WalletDelegateParams, WalletFailingNoopParams, WalletIncreasePaidStorageParams, WalletOriginateParams, WalletProvider, WalletTransferParams, WalletStakeParams, WalletUnstakeParams, WalletFinalizeUnstakeParams, WalletTransferTicketParams } from './interface';
|
|
8
|
+
import { WalletDelegateParams, WalletFailingNoopParams, WalletIncreasePaidStorageParams, WalletOriginateParams, WalletProvider, WalletTransferParams, WalletStakeParams, WalletUnstakeParams, WalletFinalizeUnstakeParams, WalletTransferTicketParams, WalletRegisterGlobalConstantParams } from './interface';
|
|
8
9
|
export interface PKHOption {
|
|
9
10
|
forceRefetch?: boolean;
|
|
10
11
|
}
|
|
11
|
-
export type WalletParamsWithKind = withKind<WalletTransferParams, OpKind.TRANSACTION> | withKind<WalletOriginateParams, OpKind.ORIGINATION> | withKind<WalletDelegateParams, OpKind.DELEGATION> | withKind<WalletIncreasePaidStorageParams, OpKind.INCREASE_PAID_STORAGE> | withKind<WalletTransferTicketParams, OpKind.TRANSFER_TICKET>;
|
|
12
|
+
export type WalletParamsWithKind = withKind<WalletTransferParams, OpKind.TRANSACTION> | withKind<WalletOriginateParams, OpKind.ORIGINATION> | withKind<WalletDelegateParams, OpKind.DELEGATION> | withKind<WalletIncreasePaidStorageParams, OpKind.INCREASE_PAID_STORAGE> | withKind<WalletTransferTicketParams, OpKind.TRANSFER_TICKET> | withKind<WalletRegisterGlobalConstantParams, OpKind.REGISTER_GLOBAL_CONSTANT>;
|
|
12
13
|
export declare class WalletOperationBatch {
|
|
13
14
|
private walletProvider;
|
|
14
15
|
private context;
|
|
@@ -24,7 +25,7 @@ export declare class WalletOperationBatch {
|
|
|
24
25
|
* @param params Call a contract method
|
|
25
26
|
* @param options Generic operation parameters
|
|
26
27
|
*/
|
|
27
|
-
withContractCall(params:
|
|
28
|
+
withContractCall(params: ContractMethodObject<Wallet>, options?: Partial<SendParams>): this;
|
|
28
29
|
/**
|
|
29
30
|
* @description Add a delegation operation to the batch
|
|
30
31
|
* @param params Delegation operation parameter
|
|
@@ -45,6 +46,11 @@ export declare class WalletOperationBatch {
|
|
|
45
46
|
* @param param TransferTicket operation parameter
|
|
46
47
|
*/
|
|
47
48
|
withTransferTicket(params: WalletTransferTicketParams): this;
|
|
49
|
+
/**
|
|
50
|
+
* @description Add a RegisterGlobalConstant operation to the batch
|
|
51
|
+
* @param param RegisterGlobalConstant operation parameter
|
|
52
|
+
*/
|
|
53
|
+
withRegisterGlobalConstant(params: WalletRegisterGlobalConstantParams): this;
|
|
48
54
|
private mapOperation;
|
|
49
55
|
/**
|
|
50
56
|
* @description Add a group operation to the batch. Operation will be applied in the order they are in the params array
|
|
@@ -165,6 +171,14 @@ export declare class Wallet {
|
|
|
165
171
|
increasePaidStorage(params: WalletIncreasePaidStorageParams): {
|
|
166
172
|
send: () => Promise<import("./increase-paid-storage-operation").IncreasePaidStorageWalletOperation>;
|
|
167
173
|
};
|
|
174
|
+
/**
|
|
175
|
+
* @description Register a Micheline expression in a global table of constants.
|
|
176
|
+
* @returns a RegisterGlobalConstantWalletOperation promise object when followed by .send()
|
|
177
|
+
* @param params operation parameter
|
|
178
|
+
*/
|
|
179
|
+
registerGlobalConstant(params: WalletRegisterGlobalConstantParams): {
|
|
180
|
+
send: () => Promise<import("./register-global-constant-operation").RegisterGlobalConstantWalletOperation>;
|
|
181
|
+
};
|
|
168
182
|
/**
|
|
169
183
|
* @description Create a batch of operation
|
|
170
184
|
* @returns A batch object from which we can add more operation or send a command to the wallet to execute the batch
|
|
@@ -178,9 +192,4 @@ export declare class Wallet {
|
|
|
178
192
|
* @throws {@link InvalidContractAddressError} If the contract address is not valid
|
|
179
193
|
*/
|
|
180
194
|
at<T extends ContractAbstraction<Wallet>>(address: string, contractAbstractionComposer?: (abs: ContractAbstraction<Wallet>, context: Context) => T): Promise<T>;
|
|
181
|
-
/**
|
|
182
|
-
* @deprecated Deprecated in favor of {@link Wallet.pk} will be removed in v19.1
|
|
183
|
-
* @description Retrieve the PK of the account that is currently in use by the wallet
|
|
184
|
-
*/
|
|
185
|
-
getPK(): Promise<string>;
|
|
186
195
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taquito/taquito",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "24.0.0-beta.0",
|
|
4
4
|
"description": "High level functionality that builds upon the other packages in the Tezos Typescript Library Suite.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tezos",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"license": "Apache-2.0",
|
|
30
30
|
"engines": {
|
|
31
|
-
"node": ">=
|
|
31
|
+
"node": ">=20"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"test": "jest --coverage",
|
|
@@ -77,13 +77,14 @@
|
|
|
77
77
|
]
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@taquito/core": "^
|
|
81
|
-
"@taquito/http-utils": "^
|
|
82
|
-
"@taquito/local-forging": "^
|
|
83
|
-
"@taquito/michel-codec": "^
|
|
84
|
-
"@taquito/michelson-encoder": "^
|
|
85
|
-
"@taquito/rpc": "^
|
|
86
|
-
"@taquito/
|
|
80
|
+
"@taquito/core": "^24.0.0-beta.0",
|
|
81
|
+
"@taquito/http-utils": "^24.0.0-beta.0",
|
|
82
|
+
"@taquito/local-forging": "^24.0.0-beta.0",
|
|
83
|
+
"@taquito/michel-codec": "^24.0.0-beta.0",
|
|
84
|
+
"@taquito/michelson-encoder": "^24.0.0-beta.0",
|
|
85
|
+
"@taquito/rpc": "^24.0.0-beta.0",
|
|
86
|
+
"@taquito/signer": "^24.0.0-beta.0",
|
|
87
|
+
"@taquito/utils": "^24.0.0-beta.0",
|
|
87
88
|
"bignumber.js": "^9.1.2",
|
|
88
89
|
"rxjs": "^7.8.2"
|
|
89
90
|
},
|
|
@@ -92,7 +93,7 @@
|
|
|
92
93
|
"@types/bluebird": "^3.5.42",
|
|
93
94
|
"@types/estree": "^1.0.5",
|
|
94
95
|
"@types/jest": "^29.5.12",
|
|
95
|
-
"@types/node": "^
|
|
96
|
+
"@types/node": "^20",
|
|
96
97
|
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
97
98
|
"@typescript-eslint/parser": "^6.21.0",
|
|
98
99
|
"buffer": "^6.0.3",
|
|
@@ -111,6 +112,7 @@
|
|
|
111
112
|
"rimraf": "^6.0.1",
|
|
112
113
|
"rollup": "^4.22.4",
|
|
113
114
|
"rollup-plugin-json": "^4.0.0",
|
|
115
|
+
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
114
116
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
115
117
|
"rx-sandbox": "^2.0.5",
|
|
116
118
|
"shelljs": "^0.8.5",
|
|
@@ -125,5 +127,5 @@
|
|
|
125
127
|
"webpack-cli": "^5.1.4",
|
|
126
128
|
"webpack-subresource-integrity": "^5.1.0"
|
|
127
129
|
},
|
|
128
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "f212ea3edaf1fac34d738b5d00a9892ab7a3b721"
|
|
129
131
|
}
|
package/dist/400.taquito.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunktaquito=self.webpackChunktaquito||[]).push([[400],{6400:()=>{}}]);
|
package/dist/993.taquito.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunktaquito=self.webpackChunktaquito||[]).push([[993],{5993:()=>{}}]);
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContractMethod = void 0;
|
|
4
|
-
const wallet_1 = require("../../wallet");
|
|
5
|
-
const contract_1 = require("../contract");
|
|
6
|
-
const errors_1 = require("../errors");
|
|
7
|
-
/**
|
|
8
|
-
* @description Utility class to send smart contract operation
|
|
9
|
-
* The format for the arguments is the flattened representation
|
|
10
|
-
*/
|
|
11
|
-
class ContractMethod {
|
|
12
|
-
constructor(provider, address, parameterSchema, name, args, isMultipleEntrypoint = true, isAnonymous = false) {
|
|
13
|
-
this.provider = provider;
|
|
14
|
-
this.address = address;
|
|
15
|
-
this.parameterSchema = parameterSchema;
|
|
16
|
-
this.name = name;
|
|
17
|
-
this.args = args;
|
|
18
|
-
this.isMultipleEntrypoint = isMultipleEntrypoint;
|
|
19
|
-
this.isAnonymous = isAnonymous;
|
|
20
|
-
}
|
|
21
|
-
validateArgs(args, schema, name) {
|
|
22
|
-
const sigs = schema.ExtractSignatures();
|
|
23
|
-
if (!sigs.find((x) => x.length === args.length)) {
|
|
24
|
-
throw new errors_1.InvalidParameterError(name, sigs, args);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @description Get the schema of the smart contract method
|
|
29
|
-
*/
|
|
30
|
-
get schema() {
|
|
31
|
-
return this.isAnonymous
|
|
32
|
-
? this.parameterSchema.ExtractSchema()[this.name]
|
|
33
|
-
: this.parameterSchema.ExtractSchema();
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @description Get the signature of the smart contract method
|
|
37
|
-
*/
|
|
38
|
-
getSignature() {
|
|
39
|
-
if (this.isAnonymous) {
|
|
40
|
-
const sig = this.parameterSchema.ExtractSignatures().find((x) => x[0] === this.name);
|
|
41
|
-
if (sig) {
|
|
42
|
-
sig.shift();
|
|
43
|
-
return sig;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
const sig = this.parameterSchema.ExtractSignatures();
|
|
48
|
-
return sig.length == 1 ? sig[0] : sig;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
* @description Send the smart contract operation
|
|
54
|
-
*
|
|
55
|
-
* @param Options generic operation parameter
|
|
56
|
-
*/
|
|
57
|
-
send(params = {}) {
|
|
58
|
-
if (this.provider instanceof wallet_1.Wallet) {
|
|
59
|
-
return this.provider
|
|
60
|
-
.transfer(this.toTransferParams(params))
|
|
61
|
-
.send();
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return this.provider.transfer(this.toTransferParams(params));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
* @description Create transfer params to be used with TezosToolkit.contract.transfer methods
|
|
70
|
-
*
|
|
71
|
-
* @param Options generic transfer operation parameters
|
|
72
|
-
*/
|
|
73
|
-
toTransferParams({ fee, gasLimit, storageLimit, source, amount = 0, mutez = false, } = {}) {
|
|
74
|
-
const fullTransferParams = {
|
|
75
|
-
to: this.address,
|
|
76
|
-
amount,
|
|
77
|
-
fee,
|
|
78
|
-
mutez,
|
|
79
|
-
source,
|
|
80
|
-
gasLimit,
|
|
81
|
-
storageLimit,
|
|
82
|
-
parameter: {
|
|
83
|
-
entrypoint: this.isMultipleEntrypoint ? this.name : contract_1.DEFAULT_SMART_CONTRACT_METHOD_NAME,
|
|
84
|
-
value: this.isAnonymous
|
|
85
|
-
? this.parameterSchema.Encode(this.name, ...this.args)
|
|
86
|
-
: this.parameterSchema.Encode(...this.args),
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
return fullTransferParams;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.ContractMethod = ContractMethod;
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const errors_1 = require("../operations/errors");
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @deprecated LambdaView has been deprecated in favor of rpc.runView to simulate calls to views following the TZIP-4 standard
|
|
16
|
-
*/
|
|
17
|
-
class LambdaView {
|
|
18
|
-
constructor(lambdaContract, viewContract, viewMethod = 'default', contractParameter = { prim: 'Unit' }) {
|
|
19
|
-
this.lambdaContract = lambdaContract;
|
|
20
|
-
this.viewContract = viewContract;
|
|
21
|
-
this.viewMethod = viewMethod;
|
|
22
|
-
this.contractParameter = contractParameter;
|
|
23
|
-
this.voidLambda = this.createVoidLambda();
|
|
24
|
-
}
|
|
25
|
-
execute() {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
try {
|
|
28
|
-
yield this.lambdaContract.methods.default(this.voidLambda).send();
|
|
29
|
-
}
|
|
30
|
-
catch (ex) {
|
|
31
|
-
if (ex instanceof errors_1.TezosOperationError) {
|
|
32
|
-
return ex.lastError.with;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
throw ex;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
createVoidLambda() {
|
|
41
|
-
const [parameter, callback] = this.getView();
|
|
42
|
-
let contractArgs = [
|
|
43
|
-
{
|
|
44
|
-
prim: 'pair',
|
|
45
|
-
args: [parameter, { prim: 'contract', args: [callback] }],
|
|
46
|
-
},
|
|
47
|
-
];
|
|
48
|
-
if (this.viewMethod === 'default') {
|
|
49
|
-
contractArgs = [{ string: '%default' }].concat(contractArgs);
|
|
50
|
-
}
|
|
51
|
-
return [
|
|
52
|
-
{ prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '0' }] },
|
|
53
|
-
{ prim: 'NONE', args: [{ prim: 'key_hash' }] },
|
|
54
|
-
{
|
|
55
|
-
prim: 'CREATE_CONTRACT',
|
|
56
|
-
args: [
|
|
57
|
-
[
|
|
58
|
-
{ prim: 'parameter', args: [callback] },
|
|
59
|
-
{ prim: 'storage', args: [{ prim: 'unit' }] },
|
|
60
|
-
{
|
|
61
|
-
prim: 'code',
|
|
62
|
-
args: [[{ prim: 'CAR' }, { prim: 'FAILWITH' }]],
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
prim: 'DIP',
|
|
69
|
-
args: [
|
|
70
|
-
[
|
|
71
|
-
{
|
|
72
|
-
prim: 'DIP',
|
|
73
|
-
args: [
|
|
74
|
-
[
|
|
75
|
-
{
|
|
76
|
-
prim: 'LAMBDA',
|
|
77
|
-
args: [
|
|
78
|
-
{
|
|
79
|
-
prim: 'pair',
|
|
80
|
-
args: [{ prim: 'address' }, { prim: 'unit' }],
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
prim: 'pair',
|
|
84
|
-
args: [{ prim: 'list', args: [{ prim: 'operation' }] }, { prim: 'unit' }],
|
|
85
|
-
},
|
|
86
|
-
[
|
|
87
|
-
{ prim: 'CAR' },
|
|
88
|
-
{ prim: 'CONTRACT', args: [callback] },
|
|
89
|
-
{
|
|
90
|
-
prim: 'IF_NONE',
|
|
91
|
-
args: [
|
|
92
|
-
[
|
|
93
|
-
{
|
|
94
|
-
prim: 'PUSH',
|
|
95
|
-
args: [{ prim: 'string' }, { string: `Callback type unmatched` }],
|
|
96
|
-
},
|
|
97
|
-
{ prim: 'FAILWITH' },
|
|
98
|
-
],
|
|
99
|
-
[],
|
|
100
|
-
],
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
prim: 'PUSH',
|
|
104
|
-
args: [parameter, this.contractParameter],
|
|
105
|
-
},
|
|
106
|
-
{ prim: 'PAIR' },
|
|
107
|
-
{
|
|
108
|
-
prim: 'DIP',
|
|
109
|
-
args: [
|
|
110
|
-
[
|
|
111
|
-
{
|
|
112
|
-
prim: 'PUSH',
|
|
113
|
-
args: [
|
|
114
|
-
{ prim: 'address' },
|
|
115
|
-
{ string: `${this.viewContract.address}%${this.viewMethod}` },
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
{ prim: 'DUP' },
|
|
119
|
-
{ prim: 'CONTRACT', args: contractArgs },
|
|
120
|
-
{
|
|
121
|
-
prim: 'IF_NONE',
|
|
122
|
-
args: [
|
|
123
|
-
[
|
|
124
|
-
{
|
|
125
|
-
prim: 'PUSH',
|
|
126
|
-
args: [
|
|
127
|
-
{ prim: 'string' },
|
|
128
|
-
{ string: `Contract does not exist` },
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
{ prim: 'FAILWITH' },
|
|
132
|
-
],
|
|
133
|
-
[{ prim: 'DIP', args: [[{ prim: 'DROP' }]] }],
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
prim: 'PUSH',
|
|
138
|
-
args: [{ prim: 'mutez' }, { int: '0' }],
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
],
|
|
142
|
-
},
|
|
143
|
-
{ prim: 'TRANSFER_TOKENS' },
|
|
144
|
-
{
|
|
145
|
-
prim: 'DIP',
|
|
146
|
-
args: [[{ prim: 'NIL', args: [{ prim: 'operation' }] }]],
|
|
147
|
-
},
|
|
148
|
-
{ prim: 'CONS' },
|
|
149
|
-
{ prim: 'DIP', args: [[{ prim: 'UNIT' }]] },
|
|
150
|
-
{ prim: 'PAIR' },
|
|
151
|
-
],
|
|
152
|
-
],
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
],
|
|
156
|
-
},
|
|
157
|
-
{ prim: 'APPLY' },
|
|
158
|
-
{
|
|
159
|
-
prim: 'DIP',
|
|
160
|
-
args: [
|
|
161
|
-
[
|
|
162
|
-
{
|
|
163
|
-
prim: 'PUSH',
|
|
164
|
-
args: [{ prim: 'address' }, { string: this.lambdaContract.address }],
|
|
165
|
-
},
|
|
166
|
-
{ prim: 'DUP' },
|
|
167
|
-
{
|
|
168
|
-
prim: 'CONTRACT',
|
|
169
|
-
args: [
|
|
170
|
-
{
|
|
171
|
-
prim: 'lambda',
|
|
172
|
-
args: [
|
|
173
|
-
{ prim: 'unit' },
|
|
174
|
-
{
|
|
175
|
-
prim: 'pair',
|
|
176
|
-
args: [
|
|
177
|
-
{ prim: 'list', args: [{ prim: 'operation' }] },
|
|
178
|
-
{ prim: 'unit' },
|
|
179
|
-
],
|
|
180
|
-
},
|
|
181
|
-
],
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
prim: 'IF_NONE',
|
|
187
|
-
args: [
|
|
188
|
-
[
|
|
189
|
-
{
|
|
190
|
-
prim: 'PUSH',
|
|
191
|
-
args: [{ prim: 'string' }, { string: `Contract does not exists` }],
|
|
192
|
-
},
|
|
193
|
-
{ prim: 'FAILWITH' },
|
|
194
|
-
],
|
|
195
|
-
[{ prim: 'DIP', args: [[{ prim: 'DROP' }]] }],
|
|
196
|
-
],
|
|
197
|
-
},
|
|
198
|
-
{ prim: 'PUSH', args: [{ prim: 'mutez' }, { int: '0' }] },
|
|
199
|
-
],
|
|
200
|
-
],
|
|
201
|
-
},
|
|
202
|
-
{ prim: 'TRANSFER_TOKENS' },
|
|
203
|
-
{
|
|
204
|
-
prim: 'DIP',
|
|
205
|
-
args: [[{ prim: 'NIL', args: [{ prim: 'operation' }] }]],
|
|
206
|
-
},
|
|
207
|
-
{ prim: 'CONS' },
|
|
208
|
-
],
|
|
209
|
-
],
|
|
210
|
-
},
|
|
211
|
-
{ prim: 'CONS' },
|
|
212
|
-
{ prim: 'DIP', args: [[{ prim: 'UNIT' }]] },
|
|
213
|
-
{ prim: 'PAIR' },
|
|
214
|
-
];
|
|
215
|
-
}
|
|
216
|
-
getView() {
|
|
217
|
-
const entrypoints = this.viewContract.entrypoints.entrypoints;
|
|
218
|
-
const entrypoint = entrypoints[this.viewMethod];
|
|
219
|
-
if (!entrypoint) {
|
|
220
|
-
throw Error(`Contract at ${this.viewContract.address} does not have entrypoint: ${this.viewMethod}`);
|
|
221
|
-
}
|
|
222
|
-
if (!('prim' in entrypoint) || !entrypoint.args) {
|
|
223
|
-
// TODO: Enhance this error message to be more descriptive
|
|
224
|
-
throw Error('Entrypoint args undefined');
|
|
225
|
-
}
|
|
226
|
-
const args = Array.from(entrypoint.args);
|
|
227
|
-
const [parameter, callbackContract] = args;
|
|
228
|
-
if ('annots' in parameter) {
|
|
229
|
-
delete parameter['annots'];
|
|
230
|
-
}
|
|
231
|
-
if (!('prim' in callbackContract) || !callbackContract.args) {
|
|
232
|
-
// TODO: Enhance this error message to be more descriptive
|
|
233
|
-
throw Error('Callback contract args undefined');
|
|
234
|
-
}
|
|
235
|
-
let message;
|
|
236
|
-
if (entrypoint.prim !== 'pair') {
|
|
237
|
-
message = `Expected {'prim': 'pair', ..} but found {'prim': ${entrypoint.prim}, ..}`;
|
|
238
|
-
}
|
|
239
|
-
else if (args.length !== 2) {
|
|
240
|
-
message = `Expected an Array of length 2, but found: ${args}`;
|
|
241
|
-
}
|
|
242
|
-
else if (callbackContract.prim !== 'contract') {
|
|
243
|
-
message = `Expected a {prim: 'contract', ...}, but found: ${callbackContract.prim}`;
|
|
244
|
-
}
|
|
245
|
-
else if (callbackContract.args && callbackContract.args.length !== 1) {
|
|
246
|
-
message = `Expected a single argument to 'contract', but found: ${callbackContract.args}`;
|
|
247
|
-
}
|
|
248
|
-
if (message)
|
|
249
|
-
throw Error(message);
|
|
250
|
-
return [parameter, callbackContract.args[0]];
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
exports.default = LambdaView;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { TransactionOperation } from '../../operations/transaction-operation';
|
|
2
|
-
import { TransferParams } from '../../operations/types';
|
|
3
|
-
import { ContractProvider } from '../interface';
|
|
4
|
-
import { TransactionWalletOperation, Wallet } from '../../wallet';
|
|
5
|
-
import { ParameterSchema } from '@taquito/michelson-encoder';
|
|
6
|
-
import { ContractMethodInterface, SendParams } from './contract-method-interface';
|
|
7
|
-
/**
|
|
8
|
-
* @description Utility class to send smart contract operation
|
|
9
|
-
* The format for the arguments is the flattened representation
|
|
10
|
-
*/
|
|
11
|
-
export declare class ContractMethod<T extends ContractProvider | Wallet> implements ContractMethodInterface {
|
|
12
|
-
private provider;
|
|
13
|
-
private address;
|
|
14
|
-
private parameterSchema;
|
|
15
|
-
private name;
|
|
16
|
-
private args;
|
|
17
|
-
private isMultipleEntrypoint;
|
|
18
|
-
private isAnonymous;
|
|
19
|
-
constructor(provider: T, address: string, parameterSchema: ParameterSchema, name: string, args: any[], isMultipleEntrypoint?: boolean, isAnonymous?: boolean);
|
|
20
|
-
private validateArgs;
|
|
21
|
-
/**
|
|
22
|
-
* @description Get the schema of the smart contract method
|
|
23
|
-
*/
|
|
24
|
-
get schema(): any;
|
|
25
|
-
/**
|
|
26
|
-
* @description Get the signature of the smart contract method
|
|
27
|
-
*/
|
|
28
|
-
getSignature(): any[] | undefined;
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* @description Send the smart contract operation
|
|
32
|
-
*
|
|
33
|
-
* @param Options generic operation parameter
|
|
34
|
-
*/
|
|
35
|
-
send(params?: Partial<SendParams>): Promise<T extends Wallet ? TransactionWalletOperation : TransactionOperation>;
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* @description Create transfer params to be used with TezosToolkit.contract.transfer methods
|
|
39
|
-
*
|
|
40
|
-
* @param Options generic transfer operation parameters
|
|
41
|
-
*/
|
|
42
|
-
toTransferParams({ fee, gasLimit, storageLimit, source, amount, mutez, }?: Partial<SendParams>): TransferParams;
|
|
43
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { MichelsonV1Expression } from '@taquito/rpc';
|
|
2
|
-
import { Contract, ContractAbstraction, WalletContract } from './contract';
|
|
3
|
-
import { ContractProvider } from './interface';
|
|
4
|
-
import { Wallet } from '../wallet';
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @deprecated LambdaView has been deprecated in favor of rpc.runView to simulate calls to views following the TZIP-4 standard
|
|
8
|
-
*/
|
|
9
|
-
export default class LambdaView {
|
|
10
|
-
private lambdaContract;
|
|
11
|
-
private viewContract;
|
|
12
|
-
readonly viewMethod: string;
|
|
13
|
-
private contractParameter;
|
|
14
|
-
readonly voidLambda: object;
|
|
15
|
-
constructor(lambdaContract: Contract | WalletContract, viewContract: ContractAbstraction<ContractProvider | Wallet>, viewMethod?: string, contractParameter?: MichelsonV1Expression);
|
|
16
|
-
execute(): Promise<any>;
|
|
17
|
-
private createVoidLambda;
|
|
18
|
-
private getView;
|
|
19
|
-
}
|