Skip to content

Commit

Permalink
Update JS SDK for ValidationResultsOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed Apr 24, 2024
1 parent db1deb2 commit 6dffdf6
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 103 deletions.
4 changes: 2 additions & 2 deletions clients/js/src/generated/types/baseExternalPluginInitInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ export function baseExternalPluginInitInfo(
>['fields']
): GetDataEnumKind<BaseExternalPluginInitInfoArgs, 'DataStore'>;
export function baseExternalPluginInitInfo<
K extends BaseExternalPluginInitInfoArgs['__kind'],
K extends BaseExternalPluginInitInfoArgs['__kind']
>(kind: K, data?: any): Extract<BaseExternalPluginInitInfoArgs, { __kind: K }> {
return Array.isArray(data)
? { __kind: kind, fields: data }
: { __kind: kind, ...(data ?? {}) };
}
export function isBaseExternalPluginInitInfo<
K extends BaseExternalPluginInitInfo['__kind'],
K extends BaseExternalPluginInitInfo['__kind']
>(
kind: K,
value: BaseExternalPluginInitInfo
Expand Down
4 changes: 2 additions & 2 deletions clients/js/src/generated/types/baseExternalPluginKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ export function baseExternalPluginKey(
data: GetDataEnumKindContent<BaseExternalPluginKeyArgs, 'DataStore'>['fields']
): GetDataEnumKind<BaseExternalPluginKeyArgs, 'DataStore'>;
export function baseExternalPluginKey<
K extends BaseExternalPluginKeyArgs['__kind'],
K extends BaseExternalPluginKeyArgs['__kind']
>(kind: K, data?: any): Extract<BaseExternalPluginKeyArgs, { __kind: K }> {
return Array.isArray(data)
? { __kind: kind, fields: data }
: { __kind: kind, ...(data ?? {}) };
}
export function isBaseExternalPluginKey<
K extends BaseExternalPluginKey['__kind'],
K extends BaseExternalPluginKey['__kind']
>(
kind: K,
value: BaseExternalPluginKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function baseExternalPluginUpdateInfo(
>['fields']
): GetDataEnumKind<BaseExternalPluginUpdateInfoArgs, 'DataStore'>;
export function baseExternalPluginUpdateInfo<
K extends BaseExternalPluginUpdateInfoArgs['__kind'],
K extends BaseExternalPluginUpdateInfoArgs['__kind']
>(
kind: K,
data?: any
Expand All @@ -101,7 +101,7 @@ export function baseExternalPluginUpdateInfo<
: { __kind: kind, ...(data ?? {}) };
}
export function isBaseExternalPluginUpdateInfo<
K extends BaseExternalPluginUpdateInfo['__kind'],
K extends BaseExternalPluginUpdateInfo['__kind']
>(
kind: K,
value: BaseExternalPluginUpdateInfo
Expand Down
12 changes: 6 additions & 6 deletions clients/js/src/generated/types/baseOracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ import {
import {
BaseExtraAccount,
BaseExtraAccountArgs,
ValidationResultsOffset,
ValidationResultsOffsetArgs,
BaseValidationResultsOffset,
BaseValidationResultsOffsetArgs,
getBaseExtraAccountSerializer,
getValidationResultsOffsetSerializer,
getBaseValidationResultsOffsetSerializer,
} from '.';

export type BaseOracle = {
baseAddress: PublicKey;
pda: Option<BaseExtraAccount>;
resultsOffset: ValidationResultsOffset;
resultsOffset: BaseValidationResultsOffset;
};

export type BaseOracleArgs = {
baseAddress: PublicKey;
pda: OptionOrNullable<BaseExtraAccountArgs>;
resultsOffset: ValidationResultsOffsetArgs;
resultsOffset: BaseValidationResultsOffsetArgs;
};

export function getBaseOracleSerializer(): Serializer<
Expand All @@ -42,7 +42,7 @@ export function getBaseOracleSerializer(): Serializer<
[
['baseAddress', publicKeySerializer()],
['pda', option(getBaseExtraAccountSerializer())],
['resultsOffset', getValidationResultsOffsetSerializer()],
['resultsOffset', getBaseValidationResultsOffsetSerializer()],
],
{ description: 'BaseOracle' }
) as Serializer<BaseOracleArgs, BaseOracle>;
Expand Down
12 changes: 6 additions & 6 deletions clients/js/src/generated/types/baseOracleInitInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ import {
BaseExtraAccountArgs,
BasePluginAuthority,
BasePluginAuthorityArgs,
BaseValidationResultsOffset,
BaseValidationResultsOffsetArgs,
ExternalCheckResult,
ExternalCheckResultArgs,
HookableLifecycleEvent,
HookableLifecycleEventArgs,
ValidationResultsOffset,
ValidationResultsOffsetArgs,
getBaseExtraAccountSerializer,
getBasePluginAuthoritySerializer,
getBaseValidationResultsOffsetSerializer,
getExternalCheckResultSerializer,
getHookableLifecycleEventSerializer,
getValidationResultsOffsetSerializer,
} from '.';

export type BaseOracleInitInfo = {
baseAddress: PublicKey;
initPluginAuthority: Option<BasePluginAuthority>;
lifecycleChecks: Option<Array<[HookableLifecycleEvent, ExternalCheckResult]>>;
pda: Option<BaseExtraAccount>;
resultsOffset: Option<ValidationResultsOffset>;
resultsOffset: Option<BaseValidationResultsOffset>;
};

export type BaseOracleInitInfoArgs = {
Expand All @@ -48,7 +48,7 @@ export type BaseOracleInitInfoArgs = {
Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]>
>;
pda: OptionOrNullable<BaseExtraAccountArgs>;
resultsOffset: OptionOrNullable<ValidationResultsOffsetArgs>;
resultsOffset: OptionOrNullable<BaseValidationResultsOffsetArgs>;
};

export function getBaseOracleInitInfoSerializer(): Serializer<
Expand All @@ -71,7 +71,7 @@ export function getBaseOracleInitInfoSerializer(): Serializer<
),
],
['pda', option(getBaseExtraAccountSerializer())],
['resultsOffset', option(getValidationResultsOffsetSerializer())],
['resultsOffset', option(getBaseValidationResultsOffsetSerializer())],
],
{ description: 'BaseOracleInitInfo' }
) as Serializer<BaseOracleInitInfoArgs, BaseOracleInitInfo>;
Expand Down
12 changes: 6 additions & 6 deletions clients/js/src/generated/types/baseOracleUpdateInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@ import {
import {
BaseExtraAccount,
BaseExtraAccountArgs,
BaseValidationResultsOffset,
BaseValidationResultsOffsetArgs,
ExternalCheckResult,
ExternalCheckResultArgs,
HookableLifecycleEvent,
HookableLifecycleEventArgs,
ValidationResultsOffset,
ValidationResultsOffsetArgs,
getBaseExtraAccountSerializer,
getBaseValidationResultsOffsetSerializer,
getExternalCheckResultSerializer,
getHookableLifecycleEventSerializer,
getValidationResultsOffsetSerializer,
} from '.';

export type BaseOracleUpdateInfo = {
lifecycleChecks: Option<Array<[HookableLifecycleEvent, ExternalCheckResult]>>;
pda: Option<BaseExtraAccount>;
resultsOffset: Option<ValidationResultsOffset>;
resultsOffset: Option<BaseValidationResultsOffset>;
};

export type BaseOracleUpdateInfoArgs = {
lifecycleChecks: OptionOrNullable<
Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]>
>;
pda: OptionOrNullable<BaseExtraAccountArgs>;
resultsOffset: OptionOrNullable<ValidationResultsOffsetArgs>;
resultsOffset: OptionOrNullable<BaseValidationResultsOffsetArgs>;
};

export function getBaseOracleUpdateInfoSerializer(): Serializer<
Expand All @@ -61,7 +61,7 @@ export function getBaseOracleUpdateInfoSerializer(): Serializer<
),
],
['pda', option(getBaseExtraAccountSerializer())],
['resultsOffset', option(getValidationResultsOffsetSerializer())],
['resultsOffset', option(getBaseValidationResultsOffsetSerializer())],
],
{ description: 'BaseOracleUpdateInfo' }
) as Serializer<BaseOracleUpdateInfoArgs, BaseOracleUpdateInfo>;
Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/types/basePluginAuthority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function basePluginAuthority(
data: GetDataEnumKindContent<BasePluginAuthorityArgs, 'Address'>
): GetDataEnumKind<BasePluginAuthorityArgs, 'Address'>;
export function basePluginAuthority<
K extends BasePluginAuthorityArgs['__kind'],
K extends BasePluginAuthorityArgs['__kind']
>(kind: K, data?: any): Extract<BasePluginAuthorityArgs, { __kind: K }> {
return Array.isArray(data)
? { __kind: kind, fields: data }
Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/types/baseUpdateAuthority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function baseUpdateAuthority(
data: GetDataEnumKindContent<BaseUpdateAuthorityArgs, 'Collection'>['fields']
): GetDataEnumKind<BaseUpdateAuthorityArgs, 'Collection'>;
export function baseUpdateAuthority<
K extends BaseUpdateAuthorityArgs['__kind'],
K extends BaseUpdateAuthorityArgs['__kind']
>(kind: K, data?: any): Extract<BaseUpdateAuthorityArgs, { __kind: K }> {
return Array.isArray(data)
? { __kind: kind, fields: data }
Expand Down
80 changes: 80 additions & 0 deletions clients/js/src/generated/types/baseValidationResultsOffset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* 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 {
GetDataEnumKind,
GetDataEnumKindContent,
Serializer,
dataEnum,
struct,
tuple,
u64,
unit,
} from '@metaplex-foundation/umi/serializers';

export type BaseValidationResultsOffset =
| { __kind: 'NoOffset' }
| { __kind: 'Anchor' }
| { __kind: 'Custom'; fields: [bigint] };

export type BaseValidationResultsOffsetArgs =
| { __kind: 'NoOffset' }
| { __kind: 'Anchor' }
| { __kind: 'Custom'; fields: [number | bigint] };

export function getBaseValidationResultsOffsetSerializer(): Serializer<
BaseValidationResultsOffsetArgs,
BaseValidationResultsOffset
> {
return dataEnum<BaseValidationResultsOffset>(
[
['NoOffset', unit()],
['Anchor', unit()],
[
'Custom',
struct<GetDataEnumKindContent<BaseValidationResultsOffset, 'Custom'>>([
['fields', tuple([u64()])],
]),
],
],
{ description: 'BaseValidationResultsOffset' }
) as Serializer<BaseValidationResultsOffsetArgs, BaseValidationResultsOffset>;
}

// Data Enum Helpers.
export function baseValidationResultsOffset(
kind: 'NoOffset'
): GetDataEnumKind<BaseValidationResultsOffsetArgs, 'NoOffset'>;
export function baseValidationResultsOffset(
kind: 'Anchor'
): GetDataEnumKind<BaseValidationResultsOffsetArgs, 'Anchor'>;
export function baseValidationResultsOffset(
kind: 'Custom',
data: GetDataEnumKindContent<
BaseValidationResultsOffsetArgs,
'Custom'
>['fields']
): GetDataEnumKind<BaseValidationResultsOffsetArgs, 'Custom'>;
export function baseValidationResultsOffset<
K extends BaseValidationResultsOffsetArgs['__kind']
>(
kind: K,
data?: any
): Extract<BaseValidationResultsOffsetArgs, { __kind: K }> {
return Array.isArray(data)
? { __kind: kind, fields: data }
: { __kind: kind, ...(data ?? {}) };
}
export function isBaseValidationResultsOffset<
K extends BaseValidationResultsOffset['__kind']
>(
kind: K,
value: BaseValidationResultsOffset
): value is BaseValidationResultsOffset & { __kind: K } {
return value.__kind === kind;
}
2 changes: 1 addition & 1 deletion clients/js/src/generated/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export * from './baseRoyalties';
export * from './baseRuleSet';
export * from './baseSeed';
export * from './baseUpdateAuthority';
export * from './baseValidationResultsOffset';
export * from './burnDelegate';
export * from './compressionProof';
export * from './creator';
Expand Down Expand Up @@ -53,4 +54,3 @@ export * from './registryRecord';
export * from './transferDelegate';
export * from './updateDelegate';
export * from './validationResult';
export * from './validationResultsOffset';
74 changes: 0 additions & 74 deletions clients/js/src/generated/types/validationResultsOffset.ts

This file was deleted.

4 changes: 4 additions & 0 deletions clients/js/src/instructions/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ExternalPluginsList,
isExternalPluginType,
} from '../plugins/externalPlugins';
import { validationResultsOffsetToBase } from '../plugins/validationResultsOffset';

export type CreateArgs = Omit<
Parameters<typeof createV2>[1],
Expand Down Expand Up @@ -43,6 +44,9 @@ export const create = (
case 'Oracle':
assetExternalPlugins.oracles?.push({
...plugin,
resultsOffset: validationResultsOffsetToBase(
plugin.resultsOffset || { type: 'NoOffset' }
),
baseAddress: plugin.baseAddress,
authority: plugin.initPluginAuthority || {
type: 'UpdateAuthority',
Expand Down
Loading

0 comments on commit 6dffdf6

Please sign in to comment.