Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#31 Refactor: Standardize Naming Conventions to Camel Case #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sandbox_tests/JettonWallet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('JettonWallet', () => {
{
admin: deployer.address,
content: defaultContent,
wallet_code: jwallet_code,
walletCode: jwallet_code,
},
minter_code));
userWallet = async (address:Address) => blockchain.openContract(
Expand Down
4 changes: 2 additions & 2 deletions scripts/deployJettonMinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ export async function run(provider: NetworkProvider) {

const content = jettonContentToCell({type:1,uri:contentUrl});

const wallet_code = await compile('JettonWallet');
const walletCode = await compile('JettonWallet');

const minter = JettonMinter.createFromConfig({admin,
content,
wallet_code,
walletCode: walletCode,
},
await compile('JettonMinter'));

Expand Down
48 changes: 24 additions & 24 deletions wrappers/JettonMinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ export type JettonMinterContent = {
uri:string
};

export type JettonMinterConfig = {admin: Address; content: Cell; wallet_code: Cell};
export type JettonMinterConfig = {admin: Address; content: Cell; walletCode: Cell};

export function jettonMinterConfigToCell(config: JettonMinterConfig): Cell {
return beginCell()
.storeCoins(0)
.storeAddress(config.admin)
.storeRef(config.content)
.storeRef(config.wallet_code)
.storeRef(config.walletCode)
.endCell();
}

Expand Down Expand Up @@ -46,61 +46,61 @@ export class JettonMinter implements Contract {
});
}

protected static jettonInternalTransfer(jetton_amount: bigint,
forward_ton_amount: bigint,
response_addr?: Address,
query_id: number | bigint = 0) {
protected static jettonInternalTransfer(jettonAmount: bigint,
forwardTonAmount: bigint,
responseAddress?: Address,
queryId: number | bigint = 0) {
return beginCell()
.storeUint(Op.internal_transfer, 32)
.storeUint(query_id, 64)
.storeCoins(jetton_amount)
.storeUint(queryId, 64)
.storeCoins(jettonAmount)
.storeAddress(null)
.storeAddress(response_addr)
.storeCoins(forward_ton_amount)
.storeAddress(responseAddress)
.storeCoins(forwardTonAmount)
.storeBit(false)
.endCell();

}
static mintMessage(from: Address, to: Address, jetton_amount: bigint, forward_ton_amount: bigint, total_ton_amount: bigint, query_id: number | bigint = 0) {
static mintMessage(from: Address, to: Address, jettonAmount: bigint, forwardTonAmount: bigint, totalTonAmount: bigint, queryId: number | bigint = 0) {
const mintMsg = beginCell().storeUint(Op.internal_transfer, 32)
.storeUint(0, 64)
.storeCoins(jetton_amount)
.storeCoins(jettonAmount)
.storeAddress(null)
.storeAddress(from) // Response addr
.storeCoins(forward_ton_amount)
.storeCoins(forwardTonAmount)
.storeMaybeRef(null)
.endCell();

return beginCell().storeUint(Op.mint, 32).storeUint(query_id, 64) // op, queryId
return beginCell().storeUint(Op.mint, 32).storeUint(queryId, 64) // op, queryId
.storeAddress(to)
.storeCoins(total_ton_amount)
.storeCoins(jetton_amount)
.storeCoins(totalTonAmount)
.storeCoins(jettonAmount)
.storeRef(mintMsg)
.endCell();
}
async sendMint(provider: ContractProvider, via: Sender, to: Address, jetton_amount: bigint, forward_ton_amount: bigint, total_ton_amount: bigint) {
if(total_ton_amount <= forward_ton_amount) {
async sendMint(provider: ContractProvider, via: Sender, to: Address, jettonAmount: bigint, forwardTonAmount: bigint, totalTonAmount: bigint) {
if(totalTonAmount <= forwardTonAmount) {
throw new Error("Total ton amount should be > forward amount");
}
await provider.internal(via, {
sendMode: SendMode.PAY_GAS_SEPARATELY,
body: JettonMinter.mintMessage(this.address, to, jetton_amount, forward_ton_amount, total_ton_amount),
value: total_ton_amount + toNano('0.015'),
body: JettonMinter.mintMessage(this.address, to, jettonAmount, forwardTonAmount, totalTonAmount),
value: totalTonAmount + toNano('0.015'),
});
}

/* provide_wallet_address#2c76b973 query_id:uint64 owner_address:MsgAddress include_address:Bool = InternalMsgBody;
*/
static discoveryMessage(owner: Address, include_address: boolean) {
static discoveryMessage(owner: Address, includeAddress: boolean) {
return beginCell().storeUint(0x2c76b973, 32).storeUint(0, 64) // op, queryId
.storeAddress(owner).storeBit(include_address)
.storeAddress(owner).storeBit(includeAddress)
.endCell();
}

async sendDiscovery(provider: ContractProvider, via: Sender, owner: Address, include_address: boolean, value:bigint = toNano('0.1')) {
async sendDiscovery(provider: ContractProvider, via: Sender, owner: Address, includeAddress: boolean, value:bigint = toNano('0.1')) {
await provider.internal(via, {
sendMode: SendMode.PAY_GAS_SEPARATELY,
body: JettonMinter.discoveryMessage(owner, include_address),
body: JettonMinter.discoveryMessage(owner, includeAddress),
value: value,
});
}
Expand Down
22 changes: 11 additions & 11 deletions wrappers/JettonWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,29 @@ export class JettonWallet implements Contract {
let res = await provider.get('get_wallet_data', []);
return res.stack.readBigNumber();
}
static transferMessage(jetton_amount: bigint, to: Address,
static transferMessage(jettonAmount: bigint, to: Address,
responseAddress:Address,
customPayload: Cell | null,
forward_ton_amount: bigint,
forwardTonAmount: bigint,
forwardPayload: Cell | null) {
return beginCell().storeUint(0xf8a7ea5, 32).storeUint(0, 64) // op, queryId
.storeCoins(jetton_amount).storeAddress(to)
.storeCoins(jettonAmount).storeAddress(to)
.storeAddress(responseAddress)
.storeMaybeRef(customPayload)
.storeCoins(forward_ton_amount)
.storeCoins(forwardTonAmount)
.storeMaybeRef(forwardPayload)
.endCell();
}
async sendTransfer(provider: ContractProvider, via: Sender,
value: bigint,
jetton_amount: bigint, to: Address,
jettonAmount: bigint, to: Address,
responseAddress:Address,
customPayload: Cell,
forward_ton_amount: bigint,
forwardTonAmount: bigint,
forwardPayload: Cell) {
await provider.internal(via, {
sendMode: SendMode.PAY_GAS_SEPARATELY,
body: JettonWallet.transferMessage(jetton_amount, to, responseAddress, customPayload, forward_ton_amount, forwardPayload),
body: JettonWallet.transferMessage(jettonAmount, to, responseAddress, customPayload, forwardTonAmount, forwardPayload),
value:value
});

Expand All @@ -67,22 +67,22 @@ export class JettonWallet implements Contract {
response_destination:MsgAddress custom_payload:(Maybe ^Cell)
= InternalMsgBody;
*/
static burnMessage(jetton_amount: bigint,
static burnMessage(jettonAmount: bigint,
responseAddress:Address,
customPayload: Cell | null) {
return beginCell().storeUint(0x595f07bc, 32).storeUint(0, 64) // op, queryId
.storeCoins(jetton_amount).storeAddress(responseAddress)
.storeCoins(jettonAmount).storeAddress(responseAddress)
.storeMaybeRef(customPayload)
.endCell();
}

async sendBurn(provider: ContractProvider, via: Sender, value: bigint,
jetton_amount: bigint,
jettonAmount: bigint,
responseAddress:Address,
customPayload: Cell) {
await provider.internal(via, {
sendMode: SendMode.PAY_GAS_SEPARATELY,
body: JettonWallet.burnMessage(jetton_amount, responseAddress, customPayload),
body: JettonWallet.burnMessage(jettonAmount, responseAddress, customPayload),
value:value
});

Expand Down