generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 28
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
23ba4c6
commit 747eafb
Showing
23 changed files
with
244 additions
and
110 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
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,26 @@ | ||
/** | ||
* This code was AUTOGENERATED using the kinobi library. | ||
* Please DO NOT EDIT THIS FILE, instead use visitors | ||
* to add features, then rerun kinobi to update it. | ||
* | ||
* @see https://github.com/metaplex-foundation/kinobi | ||
*/ | ||
|
||
import { Serializer, scalarEnum } from '@metaplex-foundation/umi/serializers'; | ||
|
||
export enum PluginType { | ||
Reserved, | ||
Royalties, | ||
Delegate, | ||
} | ||
|
||
export type PluginTypeArgs = PluginType; | ||
|
||
export function getPluginTypeSerializer(): Serializer< | ||
PluginTypeArgs, | ||
PluginType | ||
> { | ||
return scalarEnum<PluginType>(PluginType, { | ||
description: 'PluginType', | ||
}) as Serializer<PluginTypeArgs, PluginType>; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { generateSigner } from '@metaplex-foundation/umi'; | ||
import test from 'ava'; | ||
// import { base58 } from '@metaplex-foundation/umi/serializers'; | ||
import { Asset, DataState, create, delegate, fetchAsset, transfer } from '../src'; | ||
import { createUmi } from './_setup'; | ||
|
||
test('it can transfer an asset as the delegate', async (t) => { | ||
// Given a Umi instance and a new signer. | ||
const umi = await createUmi(); | ||
const assetAddress = generateSigner(umi); | ||
const newOwner = generateSigner(umi); | ||
const delegateAddress = generateSigner(umi); | ||
|
||
// When we create a new account. | ||
await create(umi, { | ||
dataState: DataState.AccountState, | ||
assetAddress, | ||
name: 'Test Bread', | ||
uri: 'https://example.com/bread', | ||
}).sendAndConfirm(umi); | ||
|
||
// Then an account was created with the correct data. | ||
const beforeAsset = await fetchAsset(umi, assetAddress.publicKey); | ||
// console.log("Account State:", beforeAsset); | ||
t.like(beforeAsset, <Asset>{ | ||
publicKey: assetAddress.publicKey, | ||
updateAuthority: umi.identity.publicKey, | ||
owner: umi.identity.publicKey, | ||
name: 'Test Bread', | ||
uri: 'https://example.com/bread', | ||
}); | ||
|
||
await delegate(umi, { | ||
assetAddress: assetAddress.publicKey, | ||
owner: umi.identity, | ||
delegate: delegateAddress.publicKey | ||
}).sendAndConfirm(umi); | ||
|
||
await transfer(umi, { | ||
assetAddress: assetAddress.publicKey, | ||
newOwner: newOwner.publicKey, | ||
authority: delegateAddress, | ||
compressionProof: null | ||
}).sendAndConfirm(umi); | ||
|
||
const afterAsset = await fetchAsset(umi, assetAddress.publicKey); | ||
// console.log("Account State:", afterAsset); | ||
t.like(afterAsset, <Asset>{ | ||
publicKey: assetAddress.publicKey, | ||
updateAuthority: umi.identity.publicKey, | ||
owner: newOwner.publicKey, | ||
name: 'Test Bread', | ||
uri: 'https://example.com/bread', | ||
}); | ||
}); | ||
|
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
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,17 @@ | ||
//! This code was AUTOGENERATED using the kinobi library. | ||
//! Please DO NOT EDIT THIS FILE, instead use visitors | ||
//! to add features, then rerun kinobi to update it. | ||
//! | ||
//! [https://github.com/metaplex-foundation/kinobi] | ||
//! | ||
use borsh::BorshDeserialize; | ||
use borsh::BorshSerialize; | ||
|
||
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] | ||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
pub enum PluginType { | ||
Reserved, | ||
Royalties, | ||
Delegate, | ||
} |
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
Oops, something went wrong.