Skip to content

Commit

Permalink
nwl collections ton
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAdoniev committed Jul 30, 2023
1 parent f1ffcef commit add38ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/helpers/ton/nwl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default [""];
16 changes: 14 additions & 2 deletions src/helpers/ton/ton-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface FreezeParams {

export class BridgeContract extends Contract<BridgeOptions, BridgeMethods> {
whiteListedCollections: string[] = [];
nwls: string[] = [];

constructor(provider: HttpProvider, options: BridgeOptions) {
super(provider, options);
Expand All @@ -53,6 +54,15 @@ export class BridgeContract extends Contract<BridgeOptions, BridgeMethods> {
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
Expand Down Expand Up @@ -120,7 +130,9 @@ export class BridgeContract extends Contract<BridgeOptions, BridgeMethods> {
};

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 (
Expand Down Expand Up @@ -165,7 +177,7 @@ export class BridgeContract extends Contract<BridgeOptions, BridgeMethods> {
});
}

return whitelistedCollections;
return whitelistedCollections.concat(this.nwls);
} catch (e: any) {
console.log(e.message, "error when parsing whitelisted collectons");
throw new Error(
Expand Down
1 change: 1 addition & 0 deletions src/helpers/ton/ton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export async function tonHelper(args: TonParams): Promise<TonHelper> {
address: args.bridgeAddr,
burner: args.burnerAddr,
});
bridge.init();

const ton = args.tonweb as TonWeb & TonWallet;
ton.provider.sendBoc = (b) =>
Expand Down

0 comments on commit add38ff

Please sign in to comment.