AlexG
2 years ago
5 changed files with 6 additions and 67 deletions
@ -1,48 +0,0 @@ |
|||||||
import { Address, Cell, contractAddress, StateInit } from "ton"; |
|
||||||
import BN from 'bn.js'; |
|
||||||
import qs from 'qs'; |
|
||||||
|
|
||||||
export function printSeparator() { |
|
||||||
console.log("========================================================================================"); |
|
||||||
} |
|
||||||
|
|
||||||
export function printHeader(name: string) { |
|
||||||
printSeparator(); |
|
||||||
console.log('Contract: ' + name); |
|
||||||
printSeparator(); |
|
||||||
} |
|
||||||
|
|
||||||
export function printAddress(address: Address, testnet: boolean = true) { |
|
||||||
console.log("Address: " + address.toFriendly({ testOnly: testnet })); |
|
||||||
console.log("Explorer: " + "https://" + (testnet ? 'testnet.' : '') + "tonwhales.com/explorer/address/" + address.toFriendly({ testOnly: testnet })); |
|
||||||
printSeparator(); |
|
||||||
} |
|
||||||
|
|
||||||
export function printDeploy(init: { code: Cell, data: Cell }, amount: BN, command: Cell | string, testnet: boolean = true) { |
|
||||||
|
|
||||||
// Resolve target address
|
|
||||||
let to = contractAddress({ workchain: 0, initialCode: init.code, initialData: init.data }); |
|
||||||
|
|
||||||
// Resovle init
|
|
||||||
let cell = new Cell(); |
|
||||||
new StateInit(init).writeTo(cell); |
|
||||||
let initStr = cell.toBoc({ idx: false }).toString("base64"); |
|
||||||
|
|
||||||
let link: string; |
|
||||||
if (typeof command === 'string') { |
|
||||||
link = `https://${testnet ? 'test.' : ''}tonhub.com/transfer/` + to.toFriendly({ testOnly: testnet }) + "?" + qs.stringify({ |
|
||||||
text: command, |
|
||||||
amount: amount.toString(10), |
|
||||||
init: initStr |
|
||||||
}); |
|
||||||
} else { |
|
||||||
link = `https://${testnet ? 'test.' : ''}tonhub.com/transfer/` + to.toFriendly({ testOnly: testnet }) + "?" + qs.stringify({ |
|
||||||
text: "Deploy contract", |
|
||||||
amount: amount.toString(10), |
|
||||||
init: initStr, |
|
||||||
bin: command.toBoc({ idx: false }).toString('base64'), |
|
||||||
}); |
|
||||||
} |
|
||||||
console.log("Deploy: " + link); |
|
||||||
printSeparator(); |
|
||||||
} |
|
@ -1,11 +0,0 @@ |
|||||||
import Prando from "prando"; |
|
||||||
import { Address } from "ton"; |
|
||||||
|
|
||||||
export function randomAddress(workchain: number, seed: string) { |
|
||||||
const random = new Prando(seed); |
|
||||||
const hash = Buffer.alloc(32); |
|
||||||
for (let i = 0; i < hash.length; i++) { |
|
||||||
hash[i] = random.nextInt(0, 255); |
|
||||||
} |
|
||||||
return new Address(workchain, hash); |
|
||||||
} |
|
Loading…
Reference in new issue