Variant typing is not right when calling .storage() function
Closed this issue · 2 comments
I opened a ticket first on teh Taqueria project but finally the bug is on Taquito side : TezosTaqueria/taqueria#1935
The problem is coming from a representation of a Variant containing some data on it.
Instead of being on field 0
and 1
of the object structure, it comes into fields 3
and 4
Here is the debugging of the code when the .storage() function is called
from this code
Here si the network call to the Tezos node that is OK
curl 'https://ghostnet.tezos.marigold.dev/chains/main/blocks/head/context/contracts/KT19KRnFvz9G9EU4R8Yc29tUrTyprHaTrJH4' --compressed -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0' -H 'Accept: */*' -H 'Accept-Language: en-GB,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'Referer: http://localhost:5173/' -H 'Content-Type: application/json' -H 'Origin: http://localhost:5173/' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: cross-site' -H 'TE: trailers'
Generated Taqueria classes are ok too
import { BigMap, address, mutez, nat, timestamp, unit } from "./type-aliases";
import {
ContractAbstractionFromContractType,
WalletContractAbstractionFromContractType,
} from "./type-utils";
export type STATUS =
| { aCTIVE: unit }
| {
rECOVERING: {
0: address;
1: timestamp;
};
}
| { dEAD: unit };
export type FREQUENCY =
| { sECOND: nat }
| { mINUTE: nat }
| { hOUR: nat }
| { dAY: nat }
| { wEEK: nat }
| { mONTH: nat }
| { yEAR: nat };
export type Storage = {
owners: Array<address>;
inheritors: Array<address>;
status: STATUS;
quick_recovery_stake: mutez;
quick_recovery_period: nat;
direct_debit_mandates: BigMap<
{
0: address;
1: FREQUENCY;
},
mutez
>;
direct_debit_mandates_history: BigMap<
{
0: address;
1: FREQUENCY;
},
timestamp
>;
};
type Methods = {
exec_direct_debit_mandate_XTZ: (_0: mutez, _1: FREQUENCY) => Promise<void>;
revoke_direct_debit_mandate_XTZ: (
_0: address,
_1: FREQUENCY
) => Promise<void>;
add_direct_debit_mandate_XTZ: (
_0: address,
_1: FREQUENCY,
_2: mutez
) => Promise<void>;
stop_recovery: () => Promise<void>;
claim_recovery: () => Promise<void>;
start_recover: (param: address) => Promise<void>;
transfer_XTZ: (_0: address, _1: mutez) => Promise<void>;
revoke: (param: address) => Promise<void>;
enroll: (param: address) => Promise<void>;
};
export type ExecDirectDebitMandateXTZParams = mutez;
export type RevokeDirectDebitMandateXTZParams = address;
export type AddDirectDebitMandateXTZParams = address;
export type StopRecoveryParams = unit;
export type ClaimRecoveryParams = unit;
export type StartRecoverParams = address;
export type TransferXTZParams = address;
export type RevokeParams = address;
export type EnrollParams = address;
type MethodsObject = {
exec_direct_debit_mandate_XTZ: (params: {
0: mutez;
1: FREQUENCY;
}) => Promise<void>;
revoke_direct_debit_mandate_XTZ: (params: {
0: address;
1: FREQUENCY;
}) => Promise<void>;
add_direct_debit_mandate_XTZ: (params: {
0: address;
1: FREQUENCY;
2: mutez;
}) => Promise<void>;
stop_recovery: () => Promise<void>;
claim_recovery: () => Promise<void>;
start_recover: (param: address) => Promise<void>;
transfer_XTZ: (params: { 0: address; 1: mutez }) => Promise<void>;
revoke: (param: address) => Promise<void>;
enroll: (param: address) => Promise<void>;
};
type contractTypes = {
methods: Methods;
methodsObject: MethodsObject;
storage: Storage;
code: { __type: "BankAccountCode"; protocol: string; code: object[] };
};
export type BankAccountContractType =
ContractAbstractionFromContractType<contractTypes>;
export type BankAccountWalletType =
WalletContractAbstractionFromContractType<contractTypes>;
To reproduce, you can deploy this contract on ghostnet, then you can call like here this entrypoint : https://better-call.dev/ghostnet/KT1MLSN9WuVMan7vmsTGt3tEEmNEqSbDB1Lx/interact/start_recover
(don't forget to add 1 tez on the transaction options)
It will pas the status of the smart contract to "RECOVERING" and you will be able to call the .storage() function of taquito to figure out the fields are not the 0 and 1 as expected
Very weird error, confirmed by Taqueria team
Happy that you found it :P