You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
863 lines
34 KiB
863 lines
34 KiB
import { Cell, Slice, Address, Builder, beginCell, ComputeError, TupleItem, TupleReader, Dictionary, contractAddress, ContractProvider, Sender, Contract, ContractABI, TupleBuilder, DictionaryValue } from 'ton-core'; |
|
import { ContractSystem, ContractExecutor } from 'ton-emulator'; |
|
|
|
export type StateInit = { |
|
$$type: 'StateInit'; |
|
code: Cell; |
|
data: Cell; |
|
} |
|
|
|
export function storeStateInit(src: StateInit) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeRef(src.code); |
|
b_0.storeRef(src.data); |
|
}; |
|
} |
|
|
|
export function loadStateInit(slice: Slice) { |
|
let sc_0 = slice; |
|
let _code = sc_0.loadRef(); |
|
let _data = sc_0.loadRef(); |
|
return { $$type: 'StateInit' as const, code: _code, data: _data }; |
|
} |
|
|
|
function loadTupleStateInit(source: TupleReader) { |
|
let _code = source.readCell(); |
|
let _data = source.readCell(); |
|
return { $$type: 'StateInit' as const, code: _code, data: _data }; |
|
} |
|
|
|
function storeTupleStateInit(source: StateInit) { |
|
let builder = new TupleBuilder(); |
|
builder.writeCell(source.code); |
|
builder.writeCell(source.data); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserStateInit(): DictionaryValue<StateInit> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeStateInit(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadStateInit(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type Context = { |
|
$$type: 'Context'; |
|
bounced: boolean; |
|
sender: Address; |
|
value: bigint; |
|
raw: Cell; |
|
} |
|
|
|
export function storeContext(src: Context) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeBit(src.bounced); |
|
b_0.storeAddress(src.sender); |
|
b_0.storeInt(src.value, 257); |
|
b_0.storeRef(src.raw); |
|
}; |
|
} |
|
|
|
export function loadContext(slice: Slice) { |
|
let sc_0 = slice; |
|
let _bounced = sc_0.loadBit(); |
|
let _sender = sc_0.loadAddress(); |
|
let _value = sc_0.loadIntBig(257); |
|
let _raw = sc_0.loadRef(); |
|
return { $$type: 'Context' as const, bounced: _bounced, sender: _sender, value: _value, raw: _raw }; |
|
} |
|
|
|
function loadTupleContext(source: TupleReader) { |
|
let _bounced = source.readBoolean(); |
|
let _sender = source.readAddress(); |
|
let _value = source.readBigNumber(); |
|
let _raw = source.readCell(); |
|
return { $$type: 'Context' as const, bounced: _bounced, sender: _sender, value: _value, raw: _raw }; |
|
} |
|
|
|
function storeTupleContext(source: Context) { |
|
let builder = new TupleBuilder(); |
|
builder.writeBoolean(source.bounced); |
|
builder.writeAddress(source.sender); |
|
builder.writeNumber(source.value); |
|
builder.writeSlice(source.raw); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserContext(): DictionaryValue<Context> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeContext(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadContext(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type SendParameters = { |
|
$$type: 'SendParameters'; |
|
bounce: boolean; |
|
to: Address; |
|
value: bigint; |
|
mode: bigint; |
|
body: Cell | null; |
|
code: Cell | null; |
|
data: Cell | null; |
|
} |
|
|
|
export function storeSendParameters(src: SendParameters) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeBit(src.bounce); |
|
b_0.storeAddress(src.to); |
|
b_0.storeInt(src.value, 257); |
|
b_0.storeInt(src.mode, 257); |
|
if (src.body !== null && src.body !== undefined) { b_0.storeBit(true).storeRef(src.body); } else { b_0.storeBit(false); } |
|
if (src.code !== null && src.code !== undefined) { b_0.storeBit(true).storeRef(src.code); } else { b_0.storeBit(false); } |
|
if (src.data !== null && src.data !== undefined) { b_0.storeBit(true).storeRef(src.data); } else { b_0.storeBit(false); } |
|
}; |
|
} |
|
|
|
export function loadSendParameters(slice: Slice) { |
|
let sc_0 = slice; |
|
let _bounce = sc_0.loadBit(); |
|
let _to = sc_0.loadAddress(); |
|
let _value = sc_0.loadIntBig(257); |
|
let _mode = sc_0.loadIntBig(257); |
|
let _body = sc_0.loadBit() ? sc_0.loadRef() : null; |
|
let _code = sc_0.loadBit() ? sc_0.loadRef() : null; |
|
let _data = sc_0.loadBit() ? sc_0.loadRef() : null; |
|
return { $$type: 'SendParameters' as const, bounce: _bounce, to: _to, value: _value, mode: _mode, body: _body, code: _code, data: _data }; |
|
} |
|
|
|
function loadTupleSendParameters(source: TupleReader) { |
|
let _bounce = source.readBoolean(); |
|
let _to = source.readAddress(); |
|
let _value = source.readBigNumber(); |
|
let _mode = source.readBigNumber(); |
|
let _body = source.readCellOpt(); |
|
let _code = source.readCellOpt(); |
|
let _data = source.readCellOpt(); |
|
return { $$type: 'SendParameters' as const, bounce: _bounce, to: _to, value: _value, mode: _mode, body: _body, code: _code, data: _data }; |
|
} |
|
|
|
function storeTupleSendParameters(source: SendParameters) { |
|
let builder = new TupleBuilder(); |
|
builder.writeBoolean(source.bounce); |
|
builder.writeAddress(source.to); |
|
builder.writeNumber(source.value); |
|
builder.writeNumber(source.mode); |
|
builder.writeCell(source.body); |
|
builder.writeCell(source.code); |
|
builder.writeCell(source.data); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserSendParameters(): DictionaryValue<SendParameters> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeSendParameters(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadSendParameters(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type ChangeOwner = { |
|
$$type: 'ChangeOwner'; |
|
newOwner: Address; |
|
} |
|
|
|
export function storeChangeOwner(src: ChangeOwner) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeUint(256331011, 32); |
|
b_0.storeAddress(src.newOwner); |
|
}; |
|
} |
|
|
|
export function loadChangeOwner(slice: Slice) { |
|
let sc_0 = slice; |
|
if (sc_0.loadUint(32) !== 256331011) { throw Error('Invalid prefix'); } |
|
let _newOwner = sc_0.loadAddress(); |
|
return { $$type: 'ChangeOwner' as const, newOwner: _newOwner }; |
|
} |
|
|
|
function loadTupleChangeOwner(source: TupleReader) { |
|
let _newOwner = source.readAddress(); |
|
return { $$type: 'ChangeOwner' as const, newOwner: _newOwner }; |
|
} |
|
|
|
function storeTupleChangeOwner(source: ChangeOwner) { |
|
let builder = new TupleBuilder(); |
|
builder.writeAddress(source.newOwner); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserChangeOwner(): DictionaryValue<ChangeOwner> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeChangeOwner(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadChangeOwner(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type TokenTransfer = { |
|
$$type: 'TokenTransfer'; |
|
queryId: bigint; |
|
amount: bigint; |
|
destination: Address; |
|
responseDestination: Address | null; |
|
customPayload: Cell | null; |
|
forwardTonAmount: bigint; |
|
forwardPayload: Cell; |
|
} |
|
|
|
export function storeTokenTransfer(src: TokenTransfer) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeUint(260734629, 32); |
|
b_0.storeUint(src.queryId, 64); |
|
b_0.storeCoins(src.amount); |
|
b_0.storeAddress(src.destination); |
|
if (src.responseDestination !== null && src.responseDestination !== undefined) { b_0.storeBit(true).storeAddress(src.responseDestination); } else { b_0.storeBit(false); } |
|
if (src.customPayload !== null && src.customPayload !== undefined) { b_0.storeBit(true).storeRef(src.customPayload); } else { b_0.storeBit(false); } |
|
b_0.storeCoins(src.forwardTonAmount); |
|
b_0.storeBuilder(src.forwardPayload.asBuilder()); |
|
}; |
|
} |
|
|
|
export function loadTokenTransfer(slice: Slice) { |
|
let sc_0 = slice; |
|
if (sc_0.loadUint(32) !== 260734629) { throw Error('Invalid prefix'); } |
|
let _queryId = sc_0.loadUintBig(64); |
|
let _amount = sc_0.loadCoins(); |
|
let _destination = sc_0.loadAddress(); |
|
let _responseDestination = sc_0.loadBit() ? sc_0.loadAddress() : null; |
|
let _customPayload = sc_0.loadBit() ? sc_0.loadRef() : null; |
|
let _forwardTonAmount = sc_0.loadCoins(); |
|
let _forwardPayload = sc_0.asCell(); |
|
return { $$type: 'TokenTransfer' as const, queryId: _queryId, amount: _amount, destination: _destination, responseDestination: _responseDestination, customPayload: _customPayload, forwardTonAmount: _forwardTonAmount, forwardPayload: _forwardPayload }; |
|
} |
|
|
|
function loadTupleTokenTransfer(source: TupleReader) { |
|
let _queryId = source.readBigNumber(); |
|
let _amount = source.readBigNumber(); |
|
let _destination = source.readAddress(); |
|
let _responseDestination = source.readAddressOpt(); |
|
let _customPayload = source.readCellOpt(); |
|
let _forwardTonAmount = source.readBigNumber(); |
|
let _forwardPayload = source.readCell(); |
|
return { $$type: 'TokenTransfer' as const, queryId: _queryId, amount: _amount, destination: _destination, responseDestination: _responseDestination, customPayload: _customPayload, forwardTonAmount: _forwardTonAmount, forwardPayload: _forwardPayload }; |
|
} |
|
|
|
function storeTupleTokenTransfer(source: TokenTransfer) { |
|
let builder = new TupleBuilder(); |
|
builder.writeNumber(source.queryId); |
|
builder.writeNumber(source.amount); |
|
builder.writeAddress(source.destination); |
|
builder.writeAddress(source.responseDestination); |
|
builder.writeCell(source.customPayload); |
|
builder.writeNumber(source.forwardTonAmount); |
|
builder.writeSlice(source.forwardPayload); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserTokenTransfer(): DictionaryValue<TokenTransfer> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeTokenTransfer(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadTokenTransfer(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type TokenTransferInternal = { |
|
$$type: 'TokenTransferInternal'; |
|
queryId: bigint; |
|
amount: bigint; |
|
from: Address; |
|
responseAddress: Address | null; |
|
forwardTonAmount: bigint; |
|
forwardPayload: Cell; |
|
} |
|
|
|
export function storeTokenTransferInternal(src: TokenTransferInternal) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeUint(395134233, 32); |
|
b_0.storeUint(src.queryId, 64); |
|
b_0.storeCoins(src.amount); |
|
b_0.storeAddress(src.from); |
|
if (src.responseAddress !== null && src.responseAddress !== undefined) { b_0.storeBit(true).storeAddress(src.responseAddress); } else { b_0.storeBit(false); } |
|
b_0.storeCoins(src.forwardTonAmount); |
|
b_0.storeBuilder(src.forwardPayload.asBuilder()); |
|
}; |
|
} |
|
|
|
export function loadTokenTransferInternal(slice: Slice) { |
|
let sc_0 = slice; |
|
if (sc_0.loadUint(32) !== 395134233) { throw Error('Invalid prefix'); } |
|
let _queryId = sc_0.loadUintBig(64); |
|
let _amount = sc_0.loadCoins(); |
|
let _from = sc_0.loadAddress(); |
|
let _responseAddress = sc_0.loadBit() ? sc_0.loadAddress() : null; |
|
let _forwardTonAmount = sc_0.loadCoins(); |
|
let _forwardPayload = sc_0.asCell(); |
|
return { $$type: 'TokenTransferInternal' as const, queryId: _queryId, amount: _amount, from: _from, responseAddress: _responseAddress, forwardTonAmount: _forwardTonAmount, forwardPayload: _forwardPayload }; |
|
} |
|
|
|
function loadTupleTokenTransferInternal(source: TupleReader) { |
|
let _queryId = source.readBigNumber(); |
|
let _amount = source.readBigNumber(); |
|
let _from = source.readAddress(); |
|
let _responseAddress = source.readAddressOpt(); |
|
let _forwardTonAmount = source.readBigNumber(); |
|
let _forwardPayload = source.readCell(); |
|
return { $$type: 'TokenTransferInternal' as const, queryId: _queryId, amount: _amount, from: _from, responseAddress: _responseAddress, forwardTonAmount: _forwardTonAmount, forwardPayload: _forwardPayload }; |
|
} |
|
|
|
function storeTupleTokenTransferInternal(source: TokenTransferInternal) { |
|
let builder = new TupleBuilder(); |
|
builder.writeNumber(source.queryId); |
|
builder.writeNumber(source.amount); |
|
builder.writeAddress(source.from); |
|
builder.writeAddress(source.responseAddress); |
|
builder.writeNumber(source.forwardTonAmount); |
|
builder.writeSlice(source.forwardPayload); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserTokenTransferInternal(): DictionaryValue<TokenTransferInternal> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeTokenTransferInternal(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadTokenTransferInternal(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type TokenNotification = { |
|
$$type: 'TokenNotification'; |
|
queryId: bigint; |
|
amount: bigint; |
|
from: Address; |
|
forwardPayload: Cell; |
|
} |
|
|
|
export function storeTokenNotification(src: TokenNotification) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeUint(1935855772, 32); |
|
b_0.storeUint(src.queryId, 64); |
|
b_0.storeCoins(src.amount); |
|
b_0.storeAddress(src.from); |
|
b_0.storeBuilder(src.forwardPayload.asBuilder()); |
|
}; |
|
} |
|
|
|
export function loadTokenNotification(slice: Slice) { |
|
let sc_0 = slice; |
|
if (sc_0.loadUint(32) !== 1935855772) { throw Error('Invalid prefix'); } |
|
let _queryId = sc_0.loadUintBig(64); |
|
let _amount = sc_0.loadCoins(); |
|
let _from = sc_0.loadAddress(); |
|
let _forwardPayload = sc_0.asCell(); |
|
return { $$type: 'TokenNotification' as const, queryId: _queryId, amount: _amount, from: _from, forwardPayload: _forwardPayload }; |
|
} |
|
|
|
function loadTupleTokenNotification(source: TupleReader) { |
|
let _queryId = source.readBigNumber(); |
|
let _amount = source.readBigNumber(); |
|
let _from = source.readAddress(); |
|
let _forwardPayload = source.readCell(); |
|
return { $$type: 'TokenNotification' as const, queryId: _queryId, amount: _amount, from: _from, forwardPayload: _forwardPayload }; |
|
} |
|
|
|
function storeTupleTokenNotification(source: TokenNotification) { |
|
let builder = new TupleBuilder(); |
|
builder.writeNumber(source.queryId); |
|
builder.writeNumber(source.amount); |
|
builder.writeAddress(source.from); |
|
builder.writeSlice(source.forwardPayload); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserTokenNotification(): DictionaryValue<TokenNotification> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeTokenNotification(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadTokenNotification(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type TokenBurn = { |
|
$$type: 'TokenBurn'; |
|
queryId: bigint; |
|
amount: bigint; |
|
owner: Address; |
|
responseAddress: Address | null; |
|
} |
|
|
|
export function storeTokenBurn(src: TokenBurn) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeUint(1499400124, 32); |
|
b_0.storeUint(src.queryId, 64); |
|
b_0.storeCoins(src.amount); |
|
b_0.storeAddress(src.owner); |
|
if (src.responseAddress !== null && src.responseAddress !== undefined) { b_0.storeBit(true).storeAddress(src.responseAddress); } else { b_0.storeBit(false); } |
|
}; |
|
} |
|
|
|
export function loadTokenBurn(slice: Slice) { |
|
let sc_0 = slice; |
|
if (sc_0.loadUint(32) !== 1499400124) { throw Error('Invalid prefix'); } |
|
let _queryId = sc_0.loadUintBig(64); |
|
let _amount = sc_0.loadCoins(); |
|
let _owner = sc_0.loadAddress(); |
|
let _responseAddress = sc_0.loadBit() ? sc_0.loadAddress() : null; |
|
return { $$type: 'TokenBurn' as const, queryId: _queryId, amount: _amount, owner: _owner, responseAddress: _responseAddress }; |
|
} |
|
|
|
function loadTupleTokenBurn(source: TupleReader) { |
|
let _queryId = source.readBigNumber(); |
|
let _amount = source.readBigNumber(); |
|
let _owner = source.readAddress(); |
|
let _responseAddress = source.readAddressOpt(); |
|
return { $$type: 'TokenBurn' as const, queryId: _queryId, amount: _amount, owner: _owner, responseAddress: _responseAddress }; |
|
} |
|
|
|
function storeTupleTokenBurn(source: TokenBurn) { |
|
let builder = new TupleBuilder(); |
|
builder.writeNumber(source.queryId); |
|
builder.writeNumber(source.amount); |
|
builder.writeAddress(source.owner); |
|
builder.writeAddress(source.responseAddress); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserTokenBurn(): DictionaryValue<TokenBurn> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeTokenBurn(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadTokenBurn(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type TokenBurnNotification = { |
|
$$type: 'TokenBurnNotification'; |
|
queryId: bigint; |
|
amount: bigint; |
|
owner: Address; |
|
responseAddress: Address | null; |
|
} |
|
|
|
export function storeTokenBurnNotification(src: TokenBurnNotification) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeUint(2078119902, 32); |
|
b_0.storeUint(src.queryId, 64); |
|
b_0.storeCoins(src.amount); |
|
b_0.storeAddress(src.owner); |
|
if (src.responseAddress !== null && src.responseAddress !== undefined) { b_0.storeBit(true).storeAddress(src.responseAddress); } else { b_0.storeBit(false); } |
|
}; |
|
} |
|
|
|
export function loadTokenBurnNotification(slice: Slice) { |
|
let sc_0 = slice; |
|
if (sc_0.loadUint(32) !== 2078119902) { throw Error('Invalid prefix'); } |
|
let _queryId = sc_0.loadUintBig(64); |
|
let _amount = sc_0.loadCoins(); |
|
let _owner = sc_0.loadAddress(); |
|
let _responseAddress = sc_0.loadBit() ? sc_0.loadAddress() : null; |
|
return { $$type: 'TokenBurnNotification' as const, queryId: _queryId, amount: _amount, owner: _owner, responseAddress: _responseAddress }; |
|
} |
|
|
|
function loadTupleTokenBurnNotification(source: TupleReader) { |
|
let _queryId = source.readBigNumber(); |
|
let _amount = source.readBigNumber(); |
|
let _owner = source.readAddress(); |
|
let _responseAddress = source.readAddressOpt(); |
|
return { $$type: 'TokenBurnNotification' as const, queryId: _queryId, amount: _amount, owner: _owner, responseAddress: _responseAddress }; |
|
} |
|
|
|
function storeTupleTokenBurnNotification(source: TokenBurnNotification) { |
|
let builder = new TupleBuilder(); |
|
builder.writeNumber(source.queryId); |
|
builder.writeNumber(source.amount); |
|
builder.writeAddress(source.owner); |
|
builder.writeAddress(source.responseAddress); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserTokenBurnNotification(): DictionaryValue<TokenBurnNotification> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeTokenBurnNotification(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadTokenBurnNotification(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type TokenExcesses = { |
|
$$type: 'TokenExcesses'; |
|
queryId: bigint; |
|
} |
|
|
|
export function storeTokenExcesses(src: TokenExcesses) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeUint(3576854235, 32); |
|
b_0.storeUint(src.queryId, 64); |
|
}; |
|
} |
|
|
|
export function loadTokenExcesses(slice: Slice) { |
|
let sc_0 = slice; |
|
if (sc_0.loadUint(32) !== 3576854235) { throw Error('Invalid prefix'); } |
|
let _queryId = sc_0.loadUintBig(64); |
|
return { $$type: 'TokenExcesses' as const, queryId: _queryId }; |
|
} |
|
|
|
function loadTupleTokenExcesses(source: TupleReader) { |
|
let _queryId = source.readBigNumber(); |
|
return { $$type: 'TokenExcesses' as const, queryId: _queryId }; |
|
} |
|
|
|
function storeTupleTokenExcesses(source: TokenExcesses) { |
|
let builder = new TupleBuilder(); |
|
builder.writeNumber(source.queryId); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserTokenExcesses(): DictionaryValue<TokenExcesses> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeTokenExcesses(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadTokenExcesses(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type TokenUpdateContent = { |
|
$$type: 'TokenUpdateContent'; |
|
content: Cell | null; |
|
} |
|
|
|
export function storeTokenUpdateContent(src: TokenUpdateContent) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeUint(201882270, 32); |
|
if (src.content !== null && src.content !== undefined) { b_0.storeBit(true).storeRef(src.content); } else { b_0.storeBit(false); } |
|
}; |
|
} |
|
|
|
export function loadTokenUpdateContent(slice: Slice) { |
|
let sc_0 = slice; |
|
if (sc_0.loadUint(32) !== 201882270) { throw Error('Invalid prefix'); } |
|
let _content = sc_0.loadBit() ? sc_0.loadRef() : null; |
|
return { $$type: 'TokenUpdateContent' as const, content: _content }; |
|
} |
|
|
|
function loadTupleTokenUpdateContent(source: TupleReader) { |
|
let _content = source.readCellOpt(); |
|
return { $$type: 'TokenUpdateContent' as const, content: _content }; |
|
} |
|
|
|
function storeTupleTokenUpdateContent(source: TokenUpdateContent) { |
|
let builder = new TupleBuilder(); |
|
builder.writeCell(source.content); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserTokenUpdateContent(): DictionaryValue<TokenUpdateContent> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeTokenUpdateContent(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadTokenUpdateContent(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type JettonData = { |
|
$$type: 'JettonData'; |
|
totalSupply: bigint; |
|
mintable: boolean; |
|
owner: Address; |
|
content: Cell | null; |
|
walletCode: Cell; |
|
} |
|
|
|
export function storeJettonData(src: JettonData) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeInt(src.totalSupply, 257); |
|
b_0.storeBit(src.mintable); |
|
b_0.storeAddress(src.owner); |
|
if (src.content !== null && src.content !== undefined) { b_0.storeBit(true).storeRef(src.content); } else { b_0.storeBit(false); } |
|
b_0.storeRef(src.walletCode); |
|
}; |
|
} |
|
|
|
export function loadJettonData(slice: Slice) { |
|
let sc_0 = slice; |
|
let _totalSupply = sc_0.loadIntBig(257); |
|
let _mintable = sc_0.loadBit(); |
|
let _owner = sc_0.loadAddress(); |
|
let _content = sc_0.loadBit() ? sc_0.loadRef() : null; |
|
let _walletCode = sc_0.loadRef(); |
|
return { $$type: 'JettonData' as const, totalSupply: _totalSupply, mintable: _mintable, owner: _owner, content: _content, walletCode: _walletCode }; |
|
} |
|
|
|
function loadTupleJettonData(source: TupleReader) { |
|
let _totalSupply = source.readBigNumber(); |
|
let _mintable = source.readBoolean(); |
|
let _owner = source.readAddress(); |
|
let _content = source.readCellOpt(); |
|
let _walletCode = source.readCell(); |
|
return { $$type: 'JettonData' as const, totalSupply: _totalSupply, mintable: _mintable, owner: _owner, content: _content, walletCode: _walletCode }; |
|
} |
|
|
|
function storeTupleJettonData(source: JettonData) { |
|
let builder = new TupleBuilder(); |
|
builder.writeNumber(source.totalSupply); |
|
builder.writeBoolean(source.mintable); |
|
builder.writeAddress(source.owner); |
|
builder.writeCell(source.content); |
|
builder.writeCell(source.walletCode); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserJettonData(): DictionaryValue<JettonData> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeJettonData(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadJettonData(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type JettonWalletData = { |
|
$$type: 'JettonWalletData'; |
|
balance: bigint; |
|
owner: Address; |
|
master: Address; |
|
walletCode: Cell; |
|
} |
|
|
|
export function storeJettonWalletData(src: JettonWalletData) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeInt(src.balance, 257); |
|
b_0.storeAddress(src.owner); |
|
b_0.storeAddress(src.master); |
|
b_0.storeRef(src.walletCode); |
|
}; |
|
} |
|
|
|
export function loadJettonWalletData(slice: Slice) { |
|
let sc_0 = slice; |
|
let _balance = sc_0.loadIntBig(257); |
|
let _owner = sc_0.loadAddress(); |
|
let _master = sc_0.loadAddress(); |
|
let _walletCode = sc_0.loadRef(); |
|
return { $$type: 'JettonWalletData' as const, balance: _balance, owner: _owner, master: _master, walletCode: _walletCode }; |
|
} |
|
|
|
function loadTupleJettonWalletData(source: TupleReader) { |
|
let _balance = source.readBigNumber(); |
|
let _owner = source.readAddress(); |
|
let _master = source.readAddress(); |
|
let _walletCode = source.readCell(); |
|
return { $$type: 'JettonWalletData' as const, balance: _balance, owner: _owner, master: _master, walletCode: _walletCode }; |
|
} |
|
|
|
function storeTupleJettonWalletData(source: JettonWalletData) { |
|
let builder = new TupleBuilder(); |
|
builder.writeNumber(source.balance); |
|
builder.writeAddress(source.owner); |
|
builder.writeAddress(source.master); |
|
builder.writeCell(source.walletCode); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserJettonWalletData(): DictionaryValue<JettonWalletData> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeJettonWalletData(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadJettonWalletData(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
export type Mint = { |
|
$$type: 'Mint'; |
|
amount: bigint; |
|
} |
|
|
|
export function storeMint(src: Mint) { |
|
return (builder: Builder) => { |
|
let b_0 = builder; |
|
b_0.storeUint(33240155, 32); |
|
b_0.storeInt(src.amount, 257); |
|
}; |
|
} |
|
|
|
export function loadMint(slice: Slice) { |
|
let sc_0 = slice; |
|
if (sc_0.loadUint(32) !== 33240155) { throw Error('Invalid prefix'); } |
|
let _amount = sc_0.loadIntBig(257); |
|
return { $$type: 'Mint' as const, amount: _amount }; |
|
} |
|
|
|
function loadTupleMint(source: TupleReader) { |
|
let _amount = source.readBigNumber(); |
|
return { $$type: 'Mint' as const, amount: _amount }; |
|
} |
|
|
|
function storeTupleMint(source: Mint) { |
|
let builder = new TupleBuilder(); |
|
builder.writeNumber(source.amount); |
|
return builder.build(); |
|
} |
|
|
|
function dictValueParserMint(): DictionaryValue<Mint> { |
|
return { |
|
serialize: (src, buidler) => { |
|
buidler.storeRef(beginCell().store(storeMint(src)).endCell()); |
|
}, |
|
parse: (src) => { |
|
return loadMint(src.loadRef().beginParse()); |
|
} |
|
} |
|
} |
|
async function JettonDefaultWallet_init(master: Address, owner: Address) { |
|
const __init = 'te6ccgEBBwEAPQABFP8A9KQT9LzyyAsBAgFiAgMCAs0EBQAJoUrd4AkAAdQBE9OAHkZiGJ7Z5kwGABpQI4EBAc8AAc8WAc8W'; |
|
const __code = 'te6ccgECNAEABR0AART/APSkE/S88sgLAQIBYgIDAgLKBgcCASAEBQERv9gW2eeBN4D0EQBxvd6ME4LnYerpZXPY9CdhzrJUKNs0E4TusalpWyPlmRadeW/vixHME4TujwAfLZsB5P5B1ZLNZRCcAgEgCAkCAUgVFgIBYgoLAAOnQASJRwIddJwh+VMCDXCx/eAtDTAwFxsMABkX+RcOIB+kAiUGZvBPhhAo8JMNs8VQLwKts84CCCEA+KfqW64wIgghAXjUUZuoERMMDQALQgbvLQgIAyIw2zwD2zw3EIkQeFUF8CfbPBEOEwQ2j5Ew2zwD2zw2EHgQZ1UE8CjbPOCCEFlfB7y6EQ8TEABs0x8BghAPin6luvLggdM/+gD6QAEB+kAh1wsBwwCRAZIxbeIB0gABkdSSbQHi+gBRZhYVFEMwAFjTHwGCEBeNRRm68uCB0z/6APpAAQH6QCHXCwHDAJEBkjFt4gH6AFFVFRRDMAMuj5DbPAPbPDQQVhBFVQLwKds84DDywIIREhMBFu1E0NQB+GLbPGwTFABM0x8BghBZXwe8uvLggdM/+gD6QAEB+kAh1wsBwwCRAZIxbeIUQzABGMj4QgHMVSDbPMntVCMAHIEBAdcA+kABAfpAAUMwAgEgFxgCAUgoKQIBIBkaAgEgHyAAS1cFnIcAHLAXMBywFwAcsAEszMyfkAyHIBywFwAcsAEsoHy//J0IAgEgGxwC9zIcQHKAVAHAcoAcAHKAlAFzxZQA/oCcAHKaCNusyVus7GORn8BygDIcAHKAHABygAkbrOafwHKAATwAlAEzJY0A3ABygDiJG6zmn8BygAE8AJQBMyWNANwAcoA4nABygACfwHKAALJWMyXMzMBcAHKAOIhbrPjD8kB+wCAdHgAlGwx+gAxcdch+gAx+gAwpwOrAIAASfwHK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QKPCTDbPFUC8CrbPOAgghAPin6luuMCIIIQF41FGbqDQyMCwENo+RMNs8A9s8NhB4EGdVBPAo2zzgghBZXwe8ujQvMi0DLo+Q2zwD2zw0EFYQRVUC8CnbPOAw8sCCNC4yAEzTHwGCEFlfB7y68uCB0z/6APpAAQH6QCHXCwHDAJEBkjFt4hRDMABY0x8BghAXjUUZuvLggdM/+gD6QAEB+kAh1wsBwwCRAZIxbeIB+gBRVRUUQzADIjDbPAPbPDcQiRB4VQXwJ9s8NDEyAGzTHwGCEA+KfqW68uCB0z/6APpAAQH6QCHXCwHDAJEBkjFt4gHSAAGR1JJtAeL6AFFmFhUUQzABGMj4QgHMVSDbPMntVDMAGlAjgQEBzwABzxYBzxYBFu1E0NQB+GLbPGwTNQAcgQEB1wD6QAEB+kABQzCZZpMs'; |
|
let systemCell = Cell.fromBase64(__system); |
|
let builder = new TupleBuilder(); |
|
builder.writeCell(systemCell); |
|
builder.writeAddress(master); |
|
builder.writeAddress(owner); |
|
let __stack = builder.build(); |
|
let codeCell = Cell.fromBoc(Buffer.from(__code, 'base64'))[0]; |
|
let initCell = Cell.fromBoc(Buffer.from(__init, 'base64'))[0]; |
|
let system = await ContractSystem.create(); |
|
let executor = await ContractExecutor.create({ code: initCell, data: new Cell() }, system); |
|
let res = await executor.get('init', __stack); |
|
if (!res.success) { throw Error(res.error); } |
|
if (res.exitCode !== 0 && res.exitCode !== 1) { |
|
if (JettonDefaultWallet_errors[res.exitCode]) { |
|
throw new ComputeError(JettonDefaultWallet_errors[res.exitCode].message, res.exitCode); |
|
} else { |
|
throw new ComputeError('Exit code: ' + res.exitCode, res.exitCode); |
|
} |
|
} |
|
|
|
let data = res.stack.readCell(); |
|
return { code: codeCell, data }; |
|
} |
|
|
|
const JettonDefaultWallet_errors: { [key: number]: { message: string } } = { |
|
2: { message: `Stack undeflow` }, |
|
3: { message: `Stack overflow` }, |
|
4: { message: `Integer overflow` }, |
|
5: { message: `Integer out of expected range` }, |
|
6: { message: `Invalid opcode` }, |
|
7: { message: `Type check error` }, |
|
8: { message: `Cell overflow` }, |
|
9: { message: `Cell underflow` }, |
|
10: { message: `Dictionary error` }, |
|
13: { message: `Out of gas error` }, |
|
32: { message: `Method ID not found` }, |
|
34: { message: `Action is invalid or not supported` }, |
|
37: { message: `Not enough TON` }, |
|
38: { message: `Not enough extra-currencies` }, |
|
128: { message: `Null reference exception` }, |
|
129: { message: `Invalid serialization prefix` }, |
|
130: { message: `Invalid incoming message` }, |
|
131: { message: `Constraints error` }, |
|
132: { message: `Access denied` }, |
|
133: { message: `Contract stopped` }, |
|
134: { message: `Invalid argument` }, |
|
135: { message: `Code of a contract was not found` }, |
|
136: { message: `Invalid address` }, |
|
4429: { message: `Invalid sender` }, |
|
13650: { message: `Invalid bounced message` }, |
|
16059: { message: `Invalid value` }, |
|
62972: { message: `Invalid balance` }, |
|
} |
|
|
|
export class JettonDefaultWallet implements Contract { |
|
|
|
static async init(master: Address, owner: Address) { |
|
return await JettonDefaultWallet_init(master,owner); |
|
} |
|
|
|
static async fromInit(master: Address, owner: Address) { |
|
const init = await JettonDefaultWallet_init(master,owner); |
|
const address = contractAddress(0, init); |
|
return new JettonDefaultWallet(address, init); |
|
} |
|
|
|
static fromAddress(address: Address) { |
|
return new JettonDefaultWallet(address); |
|
} |
|
|
|
readonly address: Address; |
|
readonly init?: { code: Cell, data: Cell }; |
|
readonly abi: ContractABI = { |
|
errors: JettonDefaultWallet_errors |
|
}; |
|
|
|
private constructor(address: Address, init?: { code: Cell, data: Cell }) { |
|
this.address = address; |
|
this.init = init; |
|
} |
|
|
|
async send(provider: ContractProvider, via: Sender, args: { value: bigint, bounce?: boolean| null | undefined }, message: TokenTransfer | TokenTransferInternal | TokenBurn) { |
|
|
|
let body: Cell | null = null; |
|
if (message && typeof message === 'object' && !(message instanceof Slice) && message.$$type === 'TokenTransfer') { |
|
body = beginCell().store(storeTokenTransfer(message)).endCell(); |
|
} |
|
if (message && typeof message === 'object' && !(message instanceof Slice) && message.$$type === 'TokenTransferInternal') { |
|
body = beginCell().store(storeTokenTransferInternal(message)).endCell(); |
|
} |
|
if (message && typeof message === 'object' && !(message instanceof Slice) && message.$$type === 'TokenBurn') { |
|
body = beginCell().store(storeTokenBurn(message)).endCell(); |
|
} |
|
if (body === null) { throw new Error('Invalid message type'); } |
|
|
|
await provider.internal(via, { ...args, body: body }); |
|
|
|
} |
|
|
|
async getGetWalletData(provider: ContractProvider) { |
|
let builder = new TupleBuilder(); |
|
let source = (await provider.get('get_wallet_data', builder.build())).stack; |
|
const result = loadTupleJettonWalletData(source); |
|
return result; |
|
} |
|
|
|
}
|
|
|