-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e63cb0
commit 3250f0c
Showing
4 changed files
with
70 additions
and
203 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,70 @@ | ||
import { | ||
address, | ||
appendTransactionMessageInstruction, | ||
pipe, | ||
} from '@solana/web3.js'; | ||
import test from 'ava'; | ||
import { | ||
AccountDiscriminator, | ||
Compression, | ||
DataSource, | ||
Encoding, | ||
fetchMetadata, | ||
findNonCanonicalPda, | ||
Format, | ||
getInitializeInstructionAsync, | ||
Metadata, | ||
} from '../src'; | ||
import { | ||
createDefaultSolanaClient, | ||
createDefaultTransaction, | ||
generateKeyPairSignerWithSol, | ||
signAndSendTransaction, | ||
} from './_setup'; | ||
|
||
test('non canonical, direct, with instruction data', async (t) => { | ||
// Given | ||
const client = createDefaultSolanaClient(); | ||
const authority = await generateKeyPairSignerWithSol(client); | ||
const program = address('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'); | ||
const seed = 'dummy'; | ||
|
||
// When | ||
const createIx = await getInitializeInstructionAsync({ | ||
authority, | ||
program, | ||
seed, | ||
encoding: Encoding.Utf8, | ||
compression: Compression.None, | ||
format: Format.None, | ||
dataSource: DataSource.Direct, | ||
data: null, | ||
}); | ||
await pipe( | ||
await createDefaultTransaction(client, authority), | ||
(tx) => appendTransactionMessageInstruction(createIx, tx), | ||
(tx) => signAndSendTransaction(client, tx) | ||
); | ||
|
||
// Then | ||
const [pda] = await findNonCanonicalPda({ | ||
authority: authority.address, | ||
program, | ||
seed, | ||
}); | ||
const metadata = await fetchMetadata(client.rpc, pda); | ||
t.like(metadata, <Metadata>{ | ||
discriminator: AccountDiscriminator.Metadata, | ||
// program: Address; | ||
// authority: Option<Address>; | ||
// mutable: boolean; | ||
// canonical: boolean; | ||
// seed: Seed; | ||
// encoding: Encoding; | ||
// compression: Compression; | ||
// format: Format; | ||
// dataSource: DataSource; | ||
// dataLength: number; | ||
// data: ReadonlyUint8Array; | ||
}); | ||
}); |