-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.1.13: fixed up some of the helper fns.
- Loading branch information
Showing
6 changed files
with
136 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export * from './ata'; | ||
export * from './constants'; | ||
export * from './nfts'; | ||
export * from './tensorswap'; | ||
export * from './txs'; | ||
export * from './utils'; | ||
export * from './whitelist'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { Connection, Keypair } from '@solana/web3.js'; | ||
import { | ||
TensorSwapSDK, | ||
TensorWhitelistSDK, | ||
TSWAP_TAKER_FEE_BPS, | ||
} from '@tensor-hq/tensorswap-ts'; | ||
import { expect } from 'chai'; | ||
import { buildAndSendTx } from './txs'; | ||
export { TensorSwapSDK, TensorWhitelistSDK } from '@tensor-hq/tensorswap-ts'; | ||
|
||
export const testInitWLAuthority = async ({ | ||
conn, | ||
cosigner, | ||
owner, | ||
wlSdk, | ||
}: { | ||
conn: Connection; | ||
cosigner: Keypair; | ||
owner: Keypair; | ||
wlSdk: TensorWhitelistSDK; | ||
}) => { | ||
const { | ||
tx: { ixs }, | ||
authPda, | ||
} = await wlSdk.initUpdateAuthority({ | ||
cosigner: cosigner.publicKey, | ||
owner: owner.publicKey, | ||
newCosigner: cosigner.publicKey, | ||
newOwner: owner.publicKey, | ||
}); | ||
|
||
await buildAndSendTx({ | ||
conn, | ||
payer: owner, | ||
ixs, | ||
extraSigners: [cosigner], | ||
}); | ||
|
||
let authAcc = await wlSdk.fetchAuthority(authPda); | ||
expect(authAcc.cosigner.toBase58()).to.eq(cosigner.publicKey.toBase58()); | ||
expect(authAcc.owner.toBase58()).to.eq(owner.publicKey.toBase58()); | ||
|
||
return { authPda, owner }; | ||
}; | ||
|
||
export const testInitTSwap = async ({ | ||
wlSdk, | ||
swapSdk, | ||
conn, | ||
cosigner, | ||
owner, | ||
}: { | ||
wlSdk: TensorWhitelistSDK; | ||
swapSdk: TensorSwapSDK; | ||
conn: Connection; | ||
cosigner: Keypair; | ||
owner: Keypair; | ||
}) => { | ||
// WL authority | ||
await testInitWLAuthority({ wlSdk, conn, cosigner, owner }); | ||
|
||
// Tswap | ||
const { | ||
tx: { ixs }, | ||
tswapPda, | ||
} = await swapSdk.initUpdateTSwap({ | ||
owner: owner.publicKey, | ||
newOwner: owner.publicKey, | ||
config: { | ||
feeBps: TSWAP_TAKER_FEE_BPS, | ||
}, | ||
cosigner: cosigner.publicKey, | ||
}); | ||
|
||
await buildAndSendTx({ | ||
conn, | ||
payer: owner, | ||
ixs, | ||
extraSigners: [cosigner], | ||
}); | ||
|
||
const swapAcc = await swapSdk.fetchTSwap(tswapPda); | ||
expect(swapAcc.version).eq(1); | ||
expect(swapAcc.owner.toBase58()).eq(owner.publicKey.toBase58()); | ||
expect(swapAcc.cosigner.toBase58()).eq(cosigner.publicKey.toBase58()); | ||
expect(swapAcc.feeVault.toBase58()).eq(tswapPda.toBase58()); | ||
expect(swapAcc.config.feeBps).eq(TSWAP_TAKER_FEE_BPS); | ||
|
||
return { tswapPda }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters