|
|
|
@ -1,10 +1,10 @@
|
|
|
|
|
import BN from "bn.js"; |
|
|
|
|
import { Cell, beginCell, Address } from "ton"; |
|
|
|
|
import { C7Config, SmartContract } from "ton-contract-executor"; |
|
|
|
|
import {Cell, beginCell, Address} from "ton"; |
|
|
|
|
import {C7Config, SmartContract} from "ton-contract-executor"; |
|
|
|
|
import {encodeOffChainContent, makeSnakeCell} from "./utils"; |
|
|
|
|
import { randomBytes } from "crypto"; |
|
|
|
|
import { keyPairFromSeed, KeyPair, sign } from "ton-crypto"; |
|
|
|
|
import { ExpansionPanelActions } from "@material-ui/core"; |
|
|
|
|
import {randomBytes} from "crypto"; |
|
|
|
|
import {keyPairFromSeed, KeyPair, sign} from "ton-crypto"; |
|
|
|
|
import {ExpansionPanelActions} from "@material-ui/core"; |
|
|
|
|
|
|
|
|
|
// encode contract storage according to save_data() contract method
|
|
|
|
|
|
|
|
|
@ -36,11 +36,20 @@ export function data(params: { ownerAddress: Address; collectionAddress: Address
|
|
|
|
|
return beginCell().storeRef(data_cell).storeBuffer(params.publicKey).endCell(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function collectionData(params: { code: Cell, ownerAddress: Address, ownerKey: number }): Cell { |
|
|
|
|
export function collectionData(params: { |
|
|
|
|
code: Cell, ownerAddress: Address, ownerKey: number, |
|
|
|
|
price_multiplier?: number, price_steepness?: number |
|
|
|
|
}): Cell { |
|
|
|
|
if (params.price_multiplier == undefined) { |
|
|
|
|
params.price_multiplier = 10; |
|
|
|
|
} |
|
|
|
|
if (params.price_steepness == undefined) { |
|
|
|
|
params.price_steepness = 5; |
|
|
|
|
} |
|
|
|
|
return beginCell() |
|
|
|
|
.storeRef(encodeOffChainContent("https://agorata.io/collection.json")) |
|
|
|
|
.storeRef(params.code) |
|
|
|
|
.storeRef(beginCell().endCell()) |
|
|
|
|
.storeRef(beginCell().storeUint(params.price_multiplier, 8).storeUint(params.price_steepness, 4).endCell()) |
|
|
|
|
.storeUint(params.ownerKey, 256) |
|
|
|
|
.storeAddress(params.ownerAddress) |
|
|
|
|
.endCell(); |
|
|
|
@ -54,7 +63,9 @@ export function setContractBalance(contract: SmartContract, balance: number) {
|
|
|
|
|
contract.setC7Config({balance: balance}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function TON(): number { return 1000000000; } |
|
|
|
|
export function TON(): number { |
|
|
|
|
return 1000000000; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// message encoders for all ops (see contracts/imports/constants.fc for consts)
|
|
|
|
|
|
|
|
|
@ -80,7 +91,7 @@ export function instantBuySignature(receiverAddress: Address, issuedCollectionAd
|
|
|
|
|
return sign(althash.toBuffer(), privateKey); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function instantBuyMessage(params: { receiverAddress: Address, issuedCollectionAddr: Address, price: number, domain: String, privateKey: Buffer}): Cell { |
|
|
|
|
export function instantBuyMessage(params: { receiverAddress: Address, issuedCollectionAddr: Address, price: number, domain: String, privateKey: Buffer }): Cell { |
|
|
|
|
let domainSnakeCell = makeSnakeCell(Buffer.from(params.domain)); |
|
|
|
|
let signature = instantBuySignature(params.receiverAddress, params.issuedCollectionAddr, params.price, domainSnakeCell, params.privateKey); |
|
|
|
|
console.log(signature.toString("hex").toUpperCase()); |
|
|
|
|