From add38ff012a32badaf60dd48c07eaee85db0228f Mon Sep 17 00:00:00 2001 From: AlexeyAdoniev Date: Sun, 30 Jul 2023 15:34:34 +0300 Subject: [PATCH] nwl collections ton --- src/helpers/ton/nwl.ts | 1 + src/helpers/ton/ton-bridge.ts | 16 ++++++++++++++-- src/helpers/ton/ton.ts | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/helpers/ton/nwl.ts diff --git a/src/helpers/ton/nwl.ts b/src/helpers/ton/nwl.ts new file mode 100644 index 000000000..eb40705a5 --- /dev/null +++ b/src/helpers/ton/nwl.ts @@ -0,0 +1 @@ +export default [""]; diff --git a/src/helpers/ton/ton-bridge.ts b/src/helpers/ton/ton-bridge.ts index be71fca20..4a015f143 100644 --- a/src/helpers/ton/ton-bridge.ts +++ b/src/helpers/ton/ton-bridge.ts @@ -39,6 +39,7 @@ interface FreezeParams { export class BridgeContract extends Contract { whiteListedCollections: string[] = []; + nwls: string[] = []; constructor(provider: HttpProvider, options: BridgeOptions) { super(provider, options); @@ -53,6 +54,15 @@ export class BridgeContract extends Contract { return new TextEncoder().encode(encodeURI(uri)); } + async init() { + try { + const nwls = await import("./nwl").catch((_) => undefined); + if (nwls) { + this.nwls.push(...nwls.default); + } + } catch (_) {} + } + async createWithdrawBody(params: WithdrawParams) { const cell = new Cell(); cell.bits.writeUint(0x5fcc3d14, 32); // transfer op @@ -120,7 +130,9 @@ export class BridgeContract extends Contract { }; getWhitelist = async () => { - if (this.whiteListedCollections.length) return this.whiteListedCollections; + if (this.whiteListedCollections.length) + return this.whiteListedCollections.concat(this.nwls); + const address = (await this.getAddress()).toString(); const readContract = async ( @@ -165,7 +177,7 @@ export class BridgeContract extends Contract { }); } - return whitelistedCollections; + return whitelistedCollections.concat(this.nwls); } catch (e: any) { console.log(e.message, "error when parsing whitelisted collectons"); throw new Error( diff --git a/src/helpers/ton/ton.ts b/src/helpers/ton/ton.ts index 4fb49228f..866c4a2c6 100644 --- a/src/helpers/ton/ton.ts +++ b/src/helpers/ton/ton.ts @@ -114,6 +114,7 @@ export async function tonHelper(args: TonParams): Promise { address: args.bridgeAddr, burner: args.burnerAddr, }); + bridge.init(); const ton = args.tonweb as TonWeb & TonWallet; ton.provider.sendBoc = (b) =>