-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from metaplex-foundation/danenbm/serde-pubkey…
…-display Serde Pubkey DisplayFromStr
- Loading branch information
1 parent
92a55a7
commit 3f9e025
Showing
22 changed files
with
547 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@metaplex-foundation/kinobi": patch | ||
--- | ||
|
||
Add serde DisplayFromStr for Pubkey and Vec<Pubkey> in Rust rendering. |
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
23 changes: 23 additions & 0 deletions
23
test/packages/js-experimental/src/generated/programs/pubkeyTests.ts
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,23 @@ | ||
/** | ||
* 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 { Address } from '@solana/addresses'; | ||
import { Program } from '@solana/programs'; | ||
|
||
export const PUBKEY_TESTS_PROGRAM_ADDRESS = | ||
'PubkeyTests1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d' as Address<'PubkeyTests1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d'>; | ||
|
||
export type PubkeyTestsProgram = | ||
Program<'PubkeyTests1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d'>; | ||
|
||
export function getPubkeyTestsProgram(): PubkeyTestsProgram { | ||
return { | ||
name: 'pubkeyTests', | ||
address: PUBKEY_TESTS_PROGRAM_ADDRESS, | ||
}; | ||
} |
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
117 changes: 117 additions & 0 deletions
117
test/packages/js-experimental/src/generated/types/ruleSet.ts
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,117 @@ | ||
/** | ||
* 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 { | ||
Address, | ||
getAddressDecoder, | ||
getAddressEncoder, | ||
} from '@solana/addresses'; | ||
import { | ||
Codec, | ||
Decoder, | ||
Encoder, | ||
GetDataEnumKind, | ||
GetDataEnumKindContent, | ||
combineCodec, | ||
getArrayDecoder, | ||
getArrayEncoder, | ||
getDataEnumDecoder, | ||
getDataEnumEncoder, | ||
getStructDecoder, | ||
getStructEncoder, | ||
getTupleDecoder, | ||
getTupleEncoder, | ||
getUnitDecoder, | ||
getUnitEncoder, | ||
} from '@solana/codecs'; | ||
|
||
export type RuleSet = | ||
| { __kind: 'None' } | ||
| { __kind: 'Single'; fields: [Address] } | ||
| { __kind: 'ProgramAllowList'; fields: [Array<Address>] } | ||
| { __kind: 'ProgramDenyList'; fields: [Array<Address>] }; | ||
|
||
export type RuleSetArgs = RuleSet; | ||
|
||
export function getRuleSetEncoder(): Encoder<RuleSetArgs> { | ||
return getDataEnumEncoder([ | ||
['None', getUnitEncoder()], | ||
[ | ||
'Single', | ||
getStructEncoder([['fields', getTupleEncoder([getAddressEncoder()])]]), | ||
], | ||
[ | ||
'ProgramAllowList', | ||
getStructEncoder([ | ||
['fields', getTupleEncoder([getArrayEncoder(getAddressEncoder())])], | ||
]), | ||
], | ||
[ | ||
'ProgramDenyList', | ||
getStructEncoder([ | ||
['fields', getTupleEncoder([getArrayEncoder(getAddressEncoder())])], | ||
]), | ||
], | ||
]); | ||
} | ||
|
||
export function getRuleSetDecoder(): Decoder<RuleSet> { | ||
return getDataEnumDecoder([ | ||
['None', getUnitDecoder()], | ||
[ | ||
'Single', | ||
getStructDecoder([['fields', getTupleDecoder([getAddressDecoder()])]]), | ||
], | ||
[ | ||
'ProgramAllowList', | ||
getStructDecoder([ | ||
['fields', getTupleDecoder([getArrayDecoder(getAddressDecoder())])], | ||
]), | ||
], | ||
[ | ||
'ProgramDenyList', | ||
getStructDecoder([ | ||
['fields', getTupleDecoder([getArrayDecoder(getAddressDecoder())])], | ||
]), | ||
], | ||
]); | ||
} | ||
|
||
export function getRuleSetCodec(): Codec<RuleSetArgs, RuleSet> { | ||
return combineCodec(getRuleSetEncoder(), getRuleSetDecoder()); | ||
} | ||
|
||
// Data Enum Helpers. | ||
export function ruleSet(kind: 'None'): GetDataEnumKind<RuleSetArgs, 'None'>; | ||
export function ruleSet( | ||
kind: 'Single', | ||
data: GetDataEnumKindContent<RuleSetArgs, 'Single'>['fields'] | ||
): GetDataEnumKind<RuleSetArgs, 'Single'>; | ||
export function ruleSet( | ||
kind: 'ProgramAllowList', | ||
data: GetDataEnumKindContent<RuleSetArgs, 'ProgramAllowList'>['fields'] | ||
): GetDataEnumKind<RuleSetArgs, 'ProgramAllowList'>; | ||
export function ruleSet( | ||
kind: 'ProgramDenyList', | ||
data: GetDataEnumKindContent<RuleSetArgs, 'ProgramDenyList'>['fields'] | ||
): GetDataEnumKind<RuleSetArgs, 'ProgramDenyList'>; | ||
export function ruleSet<K extends RuleSetArgs['__kind'], Data>( | ||
kind: K, | ||
data?: Data | ||
) { | ||
return Array.isArray(data) | ||
? { __kind: kind, fields: data } | ||
: { __kind: kind, ...(data ?? {}) }; | ||
} | ||
|
||
export function isRuleSet<K extends RuleSet['__kind']>( | ||
kind: K, | ||
value: RuleSet | ||
): value is RuleSet & { __kind: K } { | ||
return value.__kind === kind; | ||
} |
46 changes: 46 additions & 0 deletions
46
test/packages/js-experimental/src/generated/types/updateDelegate.ts
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,46 @@ | ||
/** | ||
* 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 { | ||
Address, | ||
getAddressDecoder, | ||
getAddressEncoder, | ||
} from '@solana/addresses'; | ||
import { | ||
Codec, | ||
Decoder, | ||
Encoder, | ||
combineCodec, | ||
getArrayDecoder, | ||
getArrayEncoder, | ||
getStructDecoder, | ||
getStructEncoder, | ||
} from '@solana/codecs'; | ||
|
||
export type UpdateDelegate = { additionalDelegates: Array<Address> }; | ||
|
||
export type UpdateDelegateArgs = UpdateDelegate; | ||
|
||
export function getUpdateDelegateEncoder(): Encoder<UpdateDelegateArgs> { | ||
return getStructEncoder([ | ||
['additionalDelegates', getArrayEncoder(getAddressEncoder())], | ||
]); | ||
} | ||
|
||
export function getUpdateDelegateDecoder(): Decoder<UpdateDelegate> { | ||
return getStructDecoder([ | ||
['additionalDelegates', getArrayDecoder(getAddressDecoder())], | ||
]); | ||
} | ||
|
||
export function getUpdateDelegateCodec(): Codec< | ||
UpdateDelegateArgs, | ||
UpdateDelegate | ||
> { | ||
return combineCodec(getUpdateDelegateEncoder(), getUpdateDelegateDecoder()); | ||
} |
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,42 @@ | ||
/** | ||
* 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 { Program, ProgramError } from '@metaplex-foundation/umi'; | ||
|
||
type ProgramErrorConstructor = new ( | ||
program: Program, | ||
cause?: Error | ||
) => ProgramError; | ||
const codeToErrorMap: Map<number, ProgramErrorConstructor> = new Map(); | ||
const nameToErrorMap: Map<string, ProgramErrorConstructor> = new Map(); | ||
|
||
/** | ||
* Attempts to resolve a custom program error from the provided error code. | ||
* @category Errors | ||
*/ | ||
export function getPubkeyTestsErrorFromCode( | ||
code: number, | ||
program: Program, | ||
cause?: Error | ||
): ProgramError | null { | ||
const constructor = codeToErrorMap.get(code); | ||
return constructor ? new constructor(program, cause) : null; | ||
} | ||
|
||
/** | ||
* Attempts to resolve a custom program error from the provided error name, i.e. 'Unauthorized'. | ||
* @category Errors | ||
*/ | ||
export function getPubkeyTestsErrorFromName( | ||
name: string, | ||
program: Program, | ||
cause?: Error | ||
): ProgramError | null { | ||
const constructor = nameToErrorMap.get(name); | ||
return constructor ? new constructor(program, cause) : null; | ||
} |
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,55 @@ | ||
/** | ||
* 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 { | ||
ClusterFilter, | ||
Context, | ||
Program, | ||
PublicKey, | ||
} from '@metaplex-foundation/umi'; | ||
import { | ||
getPubkeyTestsErrorFromCode, | ||
getPubkeyTestsErrorFromName, | ||
} from '../errors'; | ||
|
||
export const PUBKEY_TESTS_PROGRAM_ID = | ||
'PubkeyTests1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d' as PublicKey<'PubkeyTests1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d'>; | ||
|
||
export function createPubkeyTestsProgram(): Program { | ||
return { | ||
name: 'pubkeyTests', | ||
publicKey: PUBKEY_TESTS_PROGRAM_ID, | ||
getErrorFromCode(code: number, cause?: Error) { | ||
return getPubkeyTestsErrorFromCode(code, this, cause); | ||
}, | ||
getErrorFromName(name: string, cause?: Error) { | ||
return getPubkeyTestsErrorFromName(name, this, cause); | ||
}, | ||
isOnCluster() { | ||
return true; | ||
}, | ||
}; | ||
} | ||
|
||
export function getPubkeyTestsProgram<T extends Program = Program>( | ||
context: Pick<Context, 'programs'>, | ||
clusterFilter?: ClusterFilter | ||
): T { | ||
return context.programs.get<T>('pubkeyTests', clusterFilter); | ||
} | ||
|
||
export function getPubkeyTestsProgramId( | ||
context: Pick<Context, 'programs'>, | ||
clusterFilter?: ClusterFilter | ||
): PublicKey { | ||
return context.programs.getPublicKey( | ||
'pubkeyTests', | ||
PUBKEY_TESTS_PROGRAM_ID, | ||
clusterFilter | ||
); | ||
} |
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.