diff --git a/ccip/devenv/eds.go b/ccip/devenv/eds.go index bc8066ad1..38ec1adb2 100644 --- a/ccip/devenv/eds.go +++ b/ccip/devenv/eds.go @@ -21,6 +21,7 @@ import ( cldfdeployment "github.com/smartcontractkit/chainlink-deployments-framework/deployment" "github.com/smartcontractkit/chainlink-testing-framework/framework" "github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain" + "github.com/smartcontractkit/go-daml/pkg/types" "github.com/smartcontractkit/chainlink-canton/contracts" "github.com/smartcontractkit/chainlink-canton/deployment" @@ -112,7 +113,7 @@ func (c *Chain) GetExecutorSendDisclosure(ctx context.Context, message oapiCommo return edsTesthelpers.GetExecutorSendDisclosure(ctx, executorAPIClient, message, executorAddress, ccvAddresses) } -func (c *Chain) GetTokenPoolExecuteDisclosure(ctx context.Context, encodedMessageHex string, tokenPoolAddress contracts.InstanceAddress) (*edsTesthelpers.TokenPoolExecuteDisclosure, error) { +func (c *Chain) GetTokenPoolExecuteDisclosure(ctx context.Context, encodedMessageHex string, tokenPoolAddress contracts.InstanceAddress, receiver types.PARTY) (*edsTesthelpers.TokenPoolExecuteDisclosure, error) { edsURL, err := deployment.GetEDSURL(c.e.DataStore) if err != nil { return nil, err @@ -122,10 +123,10 @@ func (c *Chain) GetTokenPoolExecuteDisclosure(ctx context.Context, encodedMessag return nil, fmt.Errorf("failed to create Token Pool EDS client: %w", err) } - return edsTesthelpers.GetTokenPoolExecuteDisclosure(ctx, tokenPoolAPIClient, encodedMessageHex, tokenPoolAddress) + return edsTesthelpers.GetTokenPoolExecuteDisclosure(ctx, tokenPoolAPIClient, encodedMessageHex, tokenPoolAddress, receiver) } -func (c *Chain) GetCCIPExecuteDisclosure(ctx context.Context, encodedMessageHex string) (*edsTesthelpers.CCIPExecuteDisclosure, error) { +func (c *Chain) GetCCIPExecuteDisclosure(ctx context.Context, encodedMessageHex string, receiver types.PARTY) (*edsTesthelpers.CCIPExecuteDisclosure, error) { edsURL, err := deployment.GetEDSURL(c.e.DataStore) if err != nil { return nil, err @@ -135,10 +136,10 @@ func (c *Chain) GetCCIPExecuteDisclosure(ctx context.Context, encodedMessageHex return nil, fmt.Errorf("failed to create CCIP EDS client: %w", err) } - return edsTesthelpers.GetCCIPExecuteDisclosure(ctx, ccipAPIClient, encodedMessageHex) + return edsTesthelpers.GetCCIPExecuteDisclosure(ctx, ccipAPIClient, encodedMessageHex, receiver) } -func (c *Chain) GetCCVExecuteDisclosure(ctx context.Context, encodedMessageHex string, ccvAddress contracts.InstanceAddress) (*edsTesthelpers.CCVExecuteDisclosure, error) { +func (c *Chain) GetCCVExecuteDisclosure(ctx context.Context, encodedMessageHex string, ccvAddress contracts.InstanceAddress, receiver types.PARTY) (*edsTesthelpers.CCVExecuteDisclosure, error) { edsURL, err := deployment.GetEDSURL(c.e.DataStore) if err != nil { return nil, err @@ -148,7 +149,7 @@ func (c *Chain) GetCCVExecuteDisclosure(ctx context.Context, encodedMessageHex s return nil, fmt.Errorf("failed to create CCV EDS client: %w", err) } - return edsTesthelpers.GetCCVExecuteDisclosure(ctx, ccvAPIClient, encodedMessageHex, ccvAddress) + return edsTesthelpers.GetCCVExecuteDisclosure(ctx, ccvAPIClient, encodedMessageHex, ccvAddress, receiver) } const ( diff --git a/ccip/devenv/impl.go b/ccip/devenv/impl.go index 80c2bd1b4..abd5ea7a1 100644 --- a/ccip/devenv/impl.go +++ b/ccip/devenv/impl.go @@ -1268,6 +1268,7 @@ func (c *Chain) SendMessage(ctx context.Context, dest uint64, fields cciptestint Type oapiCommon.MessageExecutorType `json:"type"` }{Type: oapiCommon.Empty}, // Using default Executor Payload: hex.EncodeToString(fields.Data), + Sender: party, Receiver: hex.EncodeToString(fields.Receiver), } if hasTokenTransfer { diff --git a/ccip/devenv/manual_execution.go b/ccip/devenv/manual_execution.go index 83ac88012..41955b7bb 100644 --- a/ccip/devenv/manual_execution.go +++ b/ccip/devenv/manual_execution.go @@ -307,6 +307,7 @@ func (c *Chain) ManuallyExecuteMessage(ctx context.Context, message protocol.Mes if err != nil { return cciptestinterfaces.ExecutionStateChangedEvent{}, fmt.Errorf("no canton participants configured: %w", err) } + receiverParty := types.PARTY(participant.PartyID) // Ensure that the message receiver is the party we're executing with executingParty := participant.PartyID @@ -346,7 +347,7 @@ func (c *Chain) ManuallyExecuteMessage(ctx context.Context, message protocol.Mes // Collect disclosures // CCIP - ccipExecuteDisclosure, err := c.GetCCIPExecuteDisclosure(ctx, encodedMessageHex) + ccipExecuteDisclosure, err := c.GetCCIPExecuteDisclosure(ctx, encodedMessageHex, receiverParty) if err != nil { return cciptestinterfaces.ExecutionStateChangedEvent{}, fmt.Errorf("failed to get CCIP execute disclosure: %w", err) } @@ -365,7 +366,7 @@ func (c *Chain) ManuallyExecuteMessage(ctx context.Context, message protocol.Mes } for i, vr := range verifierResults { verifier := ccvs[i] - ccvExecuteDisclosure, err := c.GetCCVExecuteDisclosure(ctx, encodedMessageHex, verifier) + ccvExecuteDisclosure, err := c.GetCCVExecuteDisclosure(ctx, encodedMessageHex, verifier, receiverParty) if err != nil { return cciptestinterfaces.ExecutionStateChangedEvent{}, fmt.Errorf("failed to get CCV execute disclosure for verifier %s: %w", verifier.String(), err) } @@ -386,7 +387,7 @@ func (c *Chain) ManuallyExecuteMessage(ctx context.Context, message protocol.Mes return cciptestinterfaces.ExecutionStateChangedEvent{}, fmt.Errorf("failed to get token pool for token %s: %w", hashedInstrumentId.String(), err) } - tokenPoolDisclosure, err := c.GetTokenPoolExecuteDisclosure(ctx, encodedMessageHex, tokenPoolAddress.InstanceAddress()) + tokenPoolDisclosure, err := c.GetTokenPoolExecuteDisclosure(ctx, encodedMessageHex, tokenPoolAddress.InstanceAddress(), receiverParty) if err != nil { return cciptestinterfaces.ExecutionStateChangedEvent{}, fmt.Errorf("failed to get token pool execute disclosure: %w", err) } diff --git a/deployment/operations/services/eds/config.go b/deployment/operations/services/eds/config.go index c01607719..7c757397d 100644 --- a/deployment/operations/services/eds/config.go +++ b/deployment/operations/services/eds/config.go @@ -174,7 +174,7 @@ var BuildConfig = operations.NewOperation( PoolOwner: participant.PartyID, } if tokenPoolType == edsConfig.TokenPoolTypeLockRelease { - pool.TransferFactory = &edsConfig.TransferFactory{ + pool.Factory = &edsConfig.Factory{ Type: edsConfig.FactoryTypeURL, TokenStandardURL: tokenStandardURL, TokenStandardAuthConfig: tokenStandardAuthConfig, diff --git a/eds/config/config.go b/eds/config/config.go index 101824f58..8f1209239 100644 --- a/eds/config/config.go +++ b/eds/config/config.go @@ -114,31 +114,21 @@ const ( type FactoryType string const ( - FactoryTypeDisabled FactoryType = "" - FactoryTypeAddress FactoryType = "address" - FactoryTypeURL FactoryType = "url" + FactoryTypeDisabled FactoryType = "" + FactoryTypeAddress FactoryType = "address" + FactoryTypeURL FactoryType = "url" + FactoryTypeURLRequests FactoryType = "urlRequests" ) -type TransferFactory struct { - Type FactoryType `toml:"type" validate:"oneof='' address url"` +type Factory struct { + Type FactoryType `toml:"type" validate:"oneof='' address url urlRequests"` TemplateId *string `toml:"template_id" validate:"required_if=Type address"` Party *string `toml:"party" validate:"required_if=Type address"` InstanceAddress *contracts.InstanceAddress `toml:"instance_address" validate:"required_if=Type address"` - TokenStandardURL *string `toml:"token_standard_url" validate:"excluded_unless=Type url,required_if=Type url,omitnil,url"` - TokenStandardAuthConfig *commonconfig.AuthConfig `toml:"token_standard_auth" validate:"excluded_unless=Type url"` -} - -type BurnMintFactory struct { - Type FactoryType `toml:"type" validate:"oneof='' address url"` - - TemplateId *string `toml:"template_id" validate:"required_if=Type address"` - Party *string `toml:"party" validate:"required_if=Type address"` - InstanceAddress *contracts.InstanceAddress `toml:"instance_address" validate:"required_if=Type address"` - - TokenStandardURL *string `toml:"token_standard_url" validate:"excluded_unless=Type url,required_if=Type url,omitnil,url"` - TokenStandardAuthConfig *commonconfig.AuthConfig `toml:"token_standard_auth" validate:"excluded_unless=Type url"` + TokenStandardURL *string `toml:"token_standard_url" validate:"excluded_unless=Type url|excluded_unless=Type urlRequests,required_if=Type url,required_if=Type urlRequests,omitnil,url"` + TokenStandardAuthConfig *commonconfig.AuthConfig `toml:"token_standard_auth" validate:"excluded_unless=Type url|excluded_unless=Type urlRequests"` } type TokenPool struct { @@ -148,8 +138,7 @@ type TokenPool struct { // The owner party of the token pool. PoolOwner string `toml:"pool_owner" validate:"required"` - TransferFactory *TransferFactory `toml:"transfer_factory" validate:"excluded_unless=Type lockRelease"` - BurnMintFactory *BurnMintFactory `toml:"burn_mint_factory" validate:"excluded_unless=Type burnMint"` + Factory *Factory `toml:"factory" validate:"omitnil"` TransferPreapproval *TransferPreapproval `toml:"transfer_preapproval" validate:"omitnil"` } diff --git a/eds/config/config_test.go b/eds/config/config_test.go index f14059593..c23ed71dd 100644 --- a/eds/config/config_test.go +++ b/eds/config/config_test.go @@ -90,10 +90,10 @@ chain_selector = "8706591216959472610" party_id = "tokenPoolOwner" instance_address = "0xcd5fe3362a873da7d7ac7b0ae7aa23761d2c8ea7c3872dcfbc715fc8e92f0dec" pool_owner = "tokenPoolOwner" - [token_pool_api.token_pools."0xcd5fe3362a873da7d7ac7b0ae7aa23761d2c8ea7c3872dcfbc715fc8e92f0dec".transfer_factory] + [token_pool_api.token_pools."0xcd5fe3362a873da7d7ac7b0ae7aa23761d2c8ea7c3872dcfbc715fc8e92f0dec".factory] type = "url" token_standard_url = "localhost:8545" - [token_pool_api.token_pools."0xcd5fe3362a873da7d7ac7b0ae7aa23761d2c8ea7c3872dcfbc715fc8e92f0dec".transfer_factory.token_standard_auth] + [token_pool_api.token_pools."0xcd5fe3362a873da7d7ac7b0ae7aa23761d2c8ea7c3872dcfbc715fc8e92f0dec".factory.token_standard_auth] type = "insecureStatic" jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30" [token_pool_api.token_pools."0x44f3b1f70058285992aaffa899d0015ea4d9c0b5cba4ed3a90f2c99b5ca30011"] @@ -101,7 +101,7 @@ chain_selector = "8706591216959472610" party_id = "tokenPoolOwner" instance_address = "0x44f3b1f70058285992aaffa899d0015ea4d9c0b5cba4ed3a90f2c99b5ca30011" pool_owner = "tokenPoolOwner" - [token_pool_api.token_pools."0x44f3b1f70058285992aaffa899d0015ea4d9c0b5cba4ed3a90f2c99b5ca30011".burn_mint_factory] + [token_pool_api.token_pools."0x44f3b1f70058285992aaffa899d0015ea4d9c0b5cba4ed3a90f2c99b5ca30011".factory] type = "address" instance_address = "0x44f3b1f70058285992aaffa899d0015ea4d9c0b5cba4ed3a90f2c99b5ca30011" template_id = "#link:Link.Token:LinkToken" @@ -185,7 +185,7 @@ chain_selector = "8706591216959472610" InstanceAddress: contracts.HexToInstanceAddress("0xcd5fe3362a873da7d7ac7b0ae7aa23761d2c8ea7c3872dcfbc715fc8e92f0dec"), }, PoolOwner: "tokenPoolOwner", - TransferFactory: &TransferFactory{ + Factory: &Factory{ Type: FactoryTypeURL, TokenStandardURL: new("localhost:8545"), TokenStandardAuthConfig: &commonconfig.AuthConfig{ @@ -201,7 +201,7 @@ chain_selector = "8706591216959472610" InstanceAddress: contracts.HexToInstanceAddress("0x44f3b1f70058285992aaffa899d0015ea4d9c0b5cba4ed3a90f2c99b5ca30011"), }, PoolOwner: "tokenPoolOwner", - BurnMintFactory: &BurnMintFactory{ + Factory: &Factory{ Type: FactoryTypeAddress, TemplateId: new("#link:Link.Token:LinkToken"), Party: new("linkOwner"), @@ -313,7 +313,7 @@ func TestConfig_Merge(t *testing.T) { InstanceAddress: poolAddrA, }, PoolOwner: "tokenPoolOwner", - TransferFactory: &TransferFactory{ + Factory: &Factory{ Type: FactoryTypeURL, TokenStandardURL: new("http://validator/a/v0/scan-proxy"), }, @@ -344,7 +344,7 @@ func TestConfig_Merge(t *testing.T) { PartyID: "tokenPoolOwner", InstanceAddress: poolAddrA, }, - TransferFactory: &TransferFactory{ + Factory: &Factory{ TokenStandardAuthConfig: &commonconfig.AuthConfig{ Type: commonconfig.AuthTypeInsecureStatic, JWT: "jwt-token-pool-a", @@ -356,7 +356,7 @@ func TestConfig_Merge(t *testing.T) { PartyID: "tokenPoolOwner", InstanceAddress: poolAddrB, }, - BurnMintFactory: &BurnMintFactory{ + Factory: &Factory{ Type: FactoryTypeAddress, TemplateId: new("#link:Link.Token:LinkToken"), Party: new("linkOwner"), @@ -392,7 +392,7 @@ func TestConfig_Merge(t *testing.T) { InstanceAddress: poolAddrA, }, PoolOwner: "tokenPoolOwner", - TransferFactory: &TransferFactory{ + Factory: &Factory{ Type: FactoryTypeURL, TokenStandardURL: new("http://validator/a/v0/scan-proxy"), TokenStandardAuthConfig: &commonconfig.AuthConfig{ @@ -408,7 +408,7 @@ func TestConfig_Merge(t *testing.T) { InstanceAddress: poolAddrB, }, PoolOwner: "tokenPoolOwner", - BurnMintFactory: &BurnMintFactory{ + Factory: &Factory{ Type: FactoryTypeAddress, TemplateId: new("#link:Link.Token:LinkToken"), Party: new("linkOwner"), diff --git a/eds/config/config_validation_test.go b/eds/config/config_validation_test.go index 261c76488..fbdf9def4 100644 --- a/eds/config/config_validation_test.go +++ b/eds/config/config_validation_test.go @@ -31,17 +31,17 @@ func TestConfigValidation(t *testing.T) { tests := []structSuite{ { - structName: "TransferFactory", + structName: "Factory", tests: []test{ { name: "Type invalid type", - s: TransferFactory{ + s: Factory{ Type: "invalidtype", }, wantErr: true, }, { name: "Type URL valid", - s: TransferFactory{ + s: Factory{ Type: FactoryTypeURL, TokenStandardURL: new("http://eds.chain.link"), TokenStandardAuthConfig: nil, @@ -49,7 +49,7 @@ func TestConfigValidation(t *testing.T) { wantErr: false, }, { name: "Type URL valid", - s: TransferFactory{ + s: Factory{ Type: FactoryTypeURL, TokenStandardURL: new("https://eds.chain.link"), TokenStandardAuthConfig: &commonconfig.AuthConfig{ @@ -60,35 +60,65 @@ func TestConfigValidation(t *testing.T) { wantErr: false, }, { name: "Type URL invalid", - s: TransferFactory{ + s: Factory{ Type: FactoryTypeURL, - TokenStandardURL: nil, + TokenStandardURL: nil, // Required if Type = url }, wantErr: true, }, { name: "Type URL invalid", - s: TransferFactory{ + s: Factory{ Type: FactoryTypeURL, TokenStandardURL: nil, + TokenStandardAuthConfig: &commonconfig.AuthConfig{ // Must not be specified, unless TokenStandardURL is specified as well + Type: commonconfig.AuthTypeInsecureStatic, + JWT: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30", + }, + }, + wantErr: true, + }, { + name: "Type urlRequests valid", + s: Factory{ + Type: FactoryTypeURLRequests, + TokenStandardURL: new("https://eds.chain.link"), + TokenStandardAuthConfig: &commonconfig.AuthConfig{ + Type: commonconfig.AuthTypeInsecureStatic, + JWT: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30", + }, + }, + wantErr: false, + }, { + name: "Type urlRequests valid", + s: Factory{ + Type: FactoryTypeURLRequests, + TokenStandardURL: new("https://eds.chain.link"), + TokenStandardAuthConfig: nil, + }, + wantErr: false, + }, { + name: "Type urlRequests invalid", + s: Factory{ + Type: FactoryTypeURLRequests, + TokenStandardURL: nil, }, wantErr: true, }, { name: "Type Disabled valid", - s: TransferFactory{ + s: Factory{ Type: FactoryTypeDisabled, TokenStandardURL: nil, }, wantErr: false, }, { name: "Type Disabled invalid", - s: TransferFactory{ + s: Factory{ Type: FactoryTypeDisabled, TokenStandardURL: new("https://eds.chain.link"), }, wantErr: true, }, { name: "Type Address valid", - s: TransferFactory{ + s: Factory{ Type: FactoryTypeAddress, TemplateId: new("#package.module.entity"), Party: new("partyid"), @@ -97,7 +127,7 @@ func TestConfigValidation(t *testing.T) { wantErr: false, }, { name: "Type Address invalid", - s: TransferFactory{ + s: Factory{ Type: FactoryTypeAddress, TemplateId: nil, // missing Party: new("partyid"), @@ -106,7 +136,7 @@ func TestConfigValidation(t *testing.T) { wantErr: true, }, { name: "Type Address invalid", - s: TransferFactory{ + s: Factory{ Type: FactoryTypeAddress, TemplateId: new("#package.module.entity"), Party: nil, // missing @@ -115,7 +145,7 @@ func TestConfigValidation(t *testing.T) { wantErr: true, }, { name: "Type Address invalid", - s: TransferFactory{ + s: Factory{ Type: FactoryTypeAddress, TemplateId: new("#package.module.entity"), Party: new("partyid"), @@ -124,7 +154,7 @@ func TestConfigValidation(t *testing.T) { wantErr: true, }, { name: "Type Address invalid", - s: TransferFactory{ + s: Factory{ Type: FactoryTypeAddress, TemplateId: new("#package.module.entity"), Party: new("partyid"), @@ -134,7 +164,7 @@ func TestConfigValidation(t *testing.T) { wantErr: true, }, { name: "Type Address invalid", - s: TransferFactory{ + s: Factory{ Type: FactoryTypeAddress, TemplateId: new("#package.module.entity"), Party: new("partyid"), @@ -147,73 +177,6 @@ func TestConfigValidation(t *testing.T) { wantErr: true, }, }, - }, { - structName: "BurnMintFactory", - tests: []test{ - { - name: "Type invalid type", - s: BurnMintFactory{ - Type: "invalidtype", - }, - wantErr: true, - }, { - name: "Type disabled valid", - s: BurnMintFactory{ - Type: FactoryTypeDisabled, - }, - wantErr: false, - }, { - name: "Type address valid", - s: BurnMintFactory{ - Type: FactoryTypeAddress, - TemplateId: new("#package.module.entity"), - Party: new("partyid"), - InstanceAddress: new(contracts.HexToInstanceAddress("0x1234")), - }, - wantErr: false, - }, { - name: "Type Address invalid", - s: BurnMintFactory{ - Type: FactoryTypeAddress, - TemplateId: nil, // missing - Party: new("partyid"), - InstanceAddress: new(contracts.HexToInstanceAddress("0x1234")), - }, - wantErr: true, - }, { - name: "Type Address invalid", - s: BurnMintFactory{ - Type: FactoryTypeAddress, - TemplateId: new("#package.module.entity"), - Party: nil, // missing - InstanceAddress: new(contracts.HexToInstanceAddress("0x1234")), - }, - wantErr: true, - }, { - name: "Type Address invalid", - s: BurnMintFactory{ - Type: FactoryTypeAddress, - TemplateId: new("#package.module.entity"), - Party: new("partyid"), - InstanceAddress: nil, // missing - }, - wantErr: true, - }, { - name: "Type url valid", - s: BurnMintFactory{ - Type: FactoryTypeURL, - TokenStandardURL: new("https://registry.example.com"), - }, - wantErr: false, - }, { - name: "Type url invalid missing URL", - s: BurnMintFactory{ - Type: FactoryTypeURL, - TokenStandardURL: nil, // missing - }, - wantErr: true, - }, - }, }, { structName: "TokenPool", tests: []test{ @@ -226,12 +189,12 @@ func TestConfigValidation(t *testing.T) { }, Type: TokenPoolTypeBurnMint, PoolOwner: "owner", - BurnMintFactory: nil, + Factory: nil, TransferPreapproval: nil, }, wantErr: false, }, { - name: "valid BurnMintFactory", + name: "valid Factory", s: TokenPool{ ContractIdentifier: ContractIdentifier{ PartyID: "owner", @@ -239,14 +202,14 @@ func TestConfigValidation(t *testing.T) { }, Type: TokenPoolTypeBurnMint, PoolOwner: "owner", - BurnMintFactory: &BurnMintFactory{ + Factory: &Factory{ Type: FactoryTypeDisabled, }, TransferPreapproval: nil, }, wantErr: false, }, { - name: "valid TransferFactory", + name: "valid Factory", s: TokenPool{ ContractIdentifier: ContractIdentifier{ PartyID: "owner", @@ -254,7 +217,7 @@ func TestConfigValidation(t *testing.T) { }, Type: TokenPoolTypeLockRelease, PoolOwner: "owner", - TransferFactory: &TransferFactory{ + Factory: &Factory{ Type: FactoryTypeDisabled, }, TransferPreapproval: nil, @@ -269,7 +232,7 @@ func TestConfigValidation(t *testing.T) { }, Type: TokenPoolTypeBurnMint, PoolOwner: "owner", - BurnMintFactory: &BurnMintFactory{ + Factory: &Factory{ Type: FactoryTypeDisabled, }, TransferPreapproval: &TransferPreapproval{ @@ -287,7 +250,7 @@ func TestConfigValidation(t *testing.T) { }, Type: TokenPoolTypeBurnMint, PoolOwner: "owner", - BurnMintFactory: &BurnMintFactory{ + Factory: &Factory{ Type: FactoryTypeDisabled, }, TransferPreapproval: &TransferPreapproval{ @@ -297,7 +260,7 @@ func TestConfigValidation(t *testing.T) { }, wantErr: true, }, { - name: "invalid BurnMintFactory", + name: "invalid Factory", s: TokenPool{ ContractIdentifier: ContractIdentifier{ PartyID: "owner", @@ -305,56 +268,9 @@ func TestConfigValidation(t *testing.T) { }, Type: TokenPoolTypeBurnMint, PoolOwner: "owner", - BurnMintFactory: &BurnMintFactory{ - Type: FactoryTypeAddress, - }, - TransferPreapproval: nil, - }, - wantErr: true, - }, { - name: "invalid TransferFactory", - s: TokenPool{ - ContractIdentifier: ContractIdentifier{ - PartyID: "owner", - InstanceAddress: contracts.HexToInstanceAddress("0x1234"), - }, - Type: TokenPoolTypeLockRelease, - PoolOwner: "owner", - TransferFactory: &TransferFactory{ + Factory: &Factory{ Type: FactoryTypeAddress, - }, - TransferPreapproval: nil, - }, - wantErr: true, - }, { - name: "invalid TransferFactory for TokenPoolTypeBurnMint", - s: TokenPool{ - ContractIdentifier: ContractIdentifier{ - PartyID: "owner", - InstanceAddress: contracts.HexToInstanceAddress("0x1234"), - }, - Type: TokenPoolTypeBurnMint, - PoolOwner: "owner", - TransferFactory: &TransferFactory{ - Type: FactoryTypeDisabled, - }, - TransferPreapproval: nil, - }, - wantErr: true, - }, { - name: "invalid BurnMintFactory for TokenPoolTypeLockRelease", - s: TokenPool{ - ContractIdentifier: ContractIdentifier{ - PartyID: "owner", - InstanceAddress: contracts.HexToInstanceAddress("0x1234"), - }, - Type: TokenPoolTypeLockRelease, - PoolOwner: "owner", - BurnMintFactory: &BurnMintFactory{ - Type: FactoryTypeDisabled, - }, - TransferFactory: &TransferFactory{ - Type: FactoryTypeDisabled, + // Missing InstanceAddress }, TransferPreapproval: nil, }, @@ -491,7 +407,7 @@ func TestPoolOnlyEDSConfigValidate(t *testing.T) { InstanceAddress: poolAddr, }, PoolOwner: partySender, - BurnMintFactory: &BurnMintFactory{ + Factory: &Factory{ Type: FactoryTypeAddress, TemplateId: new("#link.module.entity"), Party: new(partySender), diff --git a/eds/internal/api/tokenpool/factory/burnmintfactory.go b/eds/internal/api/tokenpool/factory/burnmintfactory.go new file mode 100644 index 000000000..6f592fa2c --- /dev/null +++ b/eds/internal/api/tokenpool/factory/burnmintfactory.go @@ -0,0 +1,350 @@ +package factory + +import ( + "context" + "fmt" + "net/http" + + "github.com/smartcontractkit/chainlink-ccv/protocol" + "github.com/smartcontractkit/go-daml/pkg/types" + + "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/splice/splice_api_token_holding_v1" + "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/splice/splice_api_token_metadata_v1" + "github.com/smartcontractkit/chainlink-canton/contracts" + "github.com/smartcontractkit/chainlink-canton/eds/config" + "github.com/smartcontractkit/chainlink-canton/eds/internal/api/converters" + "github.com/smartcontractkit/chainlink-canton/eds/internal/store" + "github.com/smartcontractkit/chainlink-canton/openapi/gen/daRegistry" + oapiCommon "github.com/smartcontractkit/chainlink-canton/openapi/gen/eds/common" +) + +func NewBurnMintFactory(ctx context.Context, poolOwner types.PARTY, acs store.ActiveContractStoreInterface, cfg config.Factory) (DisclosureFactory, error) { + switch cfg.Type { + case config.FactoryTypeDisabled: + return nil, nil //nolint:nilnil + case config.FactoryTypeAddress: + factoryAddress := *cfg.InstanceAddress + + templateId, err := contracts.TemplateIDFromString(*cfg.TemplateId) + if err != nil { + return nil, fmt.Errorf("invalid TemplateId for BurnMintFactory: %w", err) + } + acs.RegisterTemplates(store.RegisteredTemplate{ + TemplateID: templateId, + PartyID: *cfg.Party, + }) + + return AddressBurnMintFactory{ + factoryAddress: factoryAddress, + acs: acs, + }, nil + case config.FactoryTypeURL, config.FactoryTypeURLRequests: + // If authentication has been configured, add an interceptor that adds the Authorization header + var options []daRegistry.ClientOption + if cfg.TokenStandardAuthConfig != nil { + authProvider, err := cfg.TokenStandardAuthConfig.NewProvider(ctx) + if err != nil { + return nil, fmt.Errorf("failed to create auth provider: %w", err) + } + // Try to get a token to validate the auth works + _, err = authProvider.TokenSource().Token() + if err != nil { + return nil, fmt.Errorf("failed to retrieve token: %w", err) + } + interceptor := func(ctx context.Context, req *http.Request) error { + token, err := authProvider.TokenSource().Token() + if err != nil { + return fmt.Errorf("failed to retrieve token: %w", err) + } + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken)) + + return nil + } + options = append(options, daRegistry.WithRequestEditorFn(interceptor)) + } + daRegistryClient, err := daRegistry.NewClientWithResponses( + *cfg.TokenStandardURL, + options..., + ) + if err != nil { + return nil, fmt.Errorf("failed to create DARegistry client with URL %q: %w", *cfg.TokenStandardURL, err) + } + + //nolint:exhaustive // these are the only two possible types + switch cfg.Type { + case config.FactoryTypeURL: + return URLBurnMintFactory{ + poolOwner: poolOwner, + daRegistryClient: daRegistryClient, + }, nil + case config.FactoryTypeURLRequests: + return RequestBurnMintFactory{ + poolOwner: poolOwner, + daRegistryClient: daRegistryClient, + }, nil + } + } + + return nil, nil //nolint:nilnil +} + +// AddressBurnMintFactory is a DisclosureFactory implementation that looks up a BurnMintFactory +// from an InstanceAddress directly. +type AddressBurnMintFactory struct { + factoryAddress contracts.InstanceAddress + acs store.ActiveContractStoreInterface +} + +func (f AddressBurnMintFactory) GetSendDisclosures(ctx context.Context, message oapiCommon.Message) (types.CONTRACT_ID, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { + activeBurnMintFactory, ok := f.acs.Get(f.factoryAddress) + if !ok { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("no active contract found for transfer factory at address %s", f.factoryAddress) + } + + return types.CONTRACT_ID(activeBurnMintFactory.GetCreatedEvent().GetContractId()), splice_api_token_metadata_v1.ChoiceContext{}, []oapiCommon.DisclosedContract{converters.ActiveContractToDisclosedContract(activeBurnMintFactory)}, nil +} + +func (f AddressBurnMintFactory) GetExecuteDisclosures(ctx context.Context, + message *protocol.Message, + instrumentId splice_api_token_holding_v1.InstrumentId, + inputHoldingCids []types.CONTRACT_ID, + receiver types.PARTY, +) (types.CONTRACT_ID, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { + activeBurnMintFactory, ok := f.acs.Get(f.factoryAddress) + if !ok { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("no active contract found for transfer factory at address %s", f.factoryAddress) + } + + return types.CONTRACT_ID(activeBurnMintFactory.GetCreatedEvent().GetContractId()), splice_api_token_metadata_v1.ChoiceContext{}, []oapiCommon.DisclosedContract{converters.ActiveContractToDisclosedContract(activeBurnMintFactory)}, nil +} + +// URLBurnMintFactory is a DisclosureFactory implementation that requests a BurnMintFactory from another URL. +// It calls DA's Registry to retrieve both the factory and ChoiceContext using the getBurnMintFactory endpoint for +// both send & execute directions. +type URLBurnMintFactory struct { + poolOwner types.PARTY + daRegistryClient daRegistry.ClientWithResponsesInterface +} + +func (f URLBurnMintFactory) GetSendDisclosures(ctx context.Context, message oapiCommon.Message) (types.CONTRACT_ID, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { + if message.TokenTransfer == nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("no TokenTransfer in message") + } + tokenTransfer := *message.TokenTransfer + instrumentId := tokenTransfer.Token + // API expects empty arrays to be `[]`, not `null` + inputHoldingCids := []string{} + if tokenTransfer.HoldingContractIds != nil { + inputHoldingCids = append(inputHoldingCids, *tokenTransfer.HoldingContractIds...) + } + + resp, err := f.daRegistryClient.GetBurnMintFactoryWithResponse(ctx, daRegistry.GetBurnMintFactoryRequest{ + InstrumentId: daRegistry.InstrumentId{ + Admin: instrumentId.Admin, + Id: instrumentId.Id, + }, + InputHoldingCids: inputHoldingCids, + Outputs: nil, // TODO: technically, this should contain the created change + }) + if err != nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to call GetBurnMintFactory: %w", err) + } + if resp.StatusCode() != http.StatusOK { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("unexpected status code: %d; response: %s", resp.StatusCode(), string(resp.Body)) + } + + disclosedContracts := make([]oapiCommon.DisclosedContract, len(resp.JSON200.ChoiceContext.DisclosedContracts)) + for i, contract := range resp.JSON200.ChoiceContext.DisclosedContracts { + synchronizerId := "" + if contract.SynchronizerId != nil { + synchronizerId = *contract.SynchronizerId + } + disclosedContracts[i] = oapiCommon.DisclosedContract{ + TemplateId: contract.TemplateId, + ContractId: contract.ContractId, + CreatedEventBlob: contract.CreatedEventBlob, + SynchronizerId: synchronizerId, + } + } + + choiceContext, err := contracts.ChoiceContextFromData(resp.JSON200.ChoiceContext.ChoiceContextData) + if err != nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to convert choice context: %w", err) + } + + return types.CONTRACT_ID(resp.JSON200.FactoryId), choiceContext, disclosedContracts, nil +} + +func (f URLBurnMintFactory) GetExecuteDisclosures(ctx context.Context, + message *protocol.Message, + instrumentId splice_api_token_holding_v1.InstrumentId, + _ []types.CONTRACT_ID, + receiver types.PARTY, +) (types.CONTRACT_ID, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { + if message.TokenTransfer == nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("no TokenTransfer in message") + } + + // TODO: for backward-compatibility, use poolOwner as receiver if not specified + if receiver == "" { + receiver = f.poolOwner + } + + resp, err := f.daRegistryClient.GetBurnMintFactoryWithResponse(ctx, daRegistry.GetBurnMintFactoryRequest{ + InstrumentId: daRegistry.InstrumentId{ + Admin: string(instrumentId.Admin), + Id: string(instrumentId.Id), + }, + InputHoldingCids: []string{}, + Outputs: []daRegistry.MintOutput{ + { + // TODO: Amount should be taken from message.TokenTransfer, but would have to be properly scaled by the TP's decimals + Amount: "1.0", + Owner: string(receiver), + }, + }, + }) + if err != nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to call GetBurnMintFactory: %w", err) + } + if resp.StatusCode() != http.StatusOK { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("unexpected status code: %d; response: %s", resp.StatusCode(), string(resp.Body)) + } + + disclosedContracts := make([]oapiCommon.DisclosedContract, len(resp.JSON200.ChoiceContext.DisclosedContracts)) + for i, contract := range resp.JSON200.ChoiceContext.DisclosedContracts { + synchronizerId := "" + if contract.SynchronizerId != nil { + synchronizerId = *contract.SynchronizerId + } + disclosedContracts[i] = oapiCommon.DisclosedContract{ + TemplateId: contract.TemplateId, + ContractId: contract.ContractId, + CreatedEventBlob: contract.CreatedEventBlob, + SynchronizerId: synchronizerId, + } + } + + choiceContext, err := contracts.ChoiceContextFromData(resp.JSON200.ChoiceContext.ChoiceContextData) + if err != nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to convert choice context: %w", err) + } + + return types.CONTRACT_ID(resp.JSON200.FactoryId), choiceContext, disclosedContracts, nil +} + +// RequestBurnMintFactory is a DisclosureFactory implementation that requests a BurnMintFactory from another URL. +// It calls DA's Registry to retrieve both the factory and ChoiceContext. +// Contrary to URLBurnMintFactory, it uses separate endpoints for send/execute: +// - getMintRequestCreateContext for execution +// - getBurnRequestCreateContext for sending +type RequestBurnMintFactory struct { + poolOwner types.PARTY + daRegistryClient daRegistry.ClientWithResponsesInterface +} + +func (f RequestBurnMintFactory) GetSendDisclosures(ctx context.Context, message oapiCommon.Message) (types.CONTRACT_ID, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { + if message.TokenTransfer == nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("no TokenTransfer in message") + } + tokenTransfer := *message.TokenTransfer + instrumentId := tokenTransfer.Token + // API expects empty arrays to be `[]`, not `null` + inputHoldingCids := []string{} + if tokenTransfer.HoldingContractIds != nil { + inputHoldingCids = append(inputHoldingCids, *tokenTransfer.HoldingContractIds...) + } + + // TODO: for backward-compatibility, use poolOwner as sender if receiver is not specified + sender := f.poolOwner + if message.Sender != "" { + sender = types.PARTY(message.Sender) + } + + resp, err := f.daRegistryClient.GetBurnRequestCreateContextWithResponse(ctx, daRegistry.RequestBurnRequest{ + InstrumentId: daRegistry.InstrumentId{ + Admin: instrumentId.Admin, + Id: instrumentId.Id, + }, + Holder: string(sender), + HoldingContractIds: inputHoldingCids, + }) + if err != nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to call GetBurnRequestCreateContext: %w", err) + } + if resp.StatusCode() != http.StatusOK { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("unexpected status code: %d; response: %s", resp.StatusCode(), string(resp.Body)) + } + + disclosedContracts := make([]oapiCommon.DisclosedContract, len(resp.JSON200.ChoiceContext.DisclosedContracts)) + for i, contract := range resp.JSON200.ChoiceContext.DisclosedContracts { + synchronizerId := "" + if contract.SynchronizerId != nil { + synchronizerId = *contract.SynchronizerId + } + disclosedContracts[i] = oapiCommon.DisclosedContract{ + TemplateId: contract.TemplateId, + ContractId: contract.ContractId, + CreatedEventBlob: contract.CreatedEventBlob, + SynchronizerId: synchronizerId, + } + } + + choiceContext, err := contracts.ChoiceContextFromData(resp.JSON200.ChoiceContext.ChoiceContextData) + if err != nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to convert choice context: %w", err) + } + + return types.CONTRACT_ID(resp.JSON200.FactoryId), choiceContext, disclosedContracts, nil +} + +func (f RequestBurnMintFactory) GetExecuteDisclosures(ctx context.Context, + message *protocol.Message, + instrumentId splice_api_token_holding_v1.InstrumentId, + _ []types.CONTRACT_ID, + receiver types.PARTY, +) (types.CONTRACT_ID, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { + if message.TokenTransfer == nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("no TokenTransfer in message") + } + + // TODO: for backward-compatibility, use poolOwner as receiver if not specified + if receiver == "" { + receiver = f.poolOwner + } + + resp, err := f.daRegistryClient.GetMintRequestCreateContextWithResponse(ctx, daRegistry.RequestMintRequest{ + InstrumentId: daRegistry.InstrumentId{ + Admin: string(instrumentId.Admin), + Id: string(instrumentId.Id), + }, + Holder: string(receiver), // The holder of the minted holdings will be the receiver + }) + if err != nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to call GetMintRequestCreateContext: %w", err) + } + if resp.StatusCode() != http.StatusOK { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("unexpected status code: %d; response: %s", resp.StatusCode(), string(resp.Body)) + } + + disclosedContracts := make([]oapiCommon.DisclosedContract, len(resp.JSON200.ChoiceContext.DisclosedContracts)) + for i, contract := range resp.JSON200.ChoiceContext.DisclosedContracts { + synchronizerId := "" + if contract.SynchronizerId != nil { + synchronizerId = *contract.SynchronizerId + } + disclosedContracts[i] = oapiCommon.DisclosedContract{ + TemplateId: contract.TemplateId, + ContractId: contract.ContractId, + CreatedEventBlob: contract.CreatedEventBlob, + SynchronizerId: synchronizerId, + } + } + + choiceContext, err := contracts.ChoiceContextFromData(resp.JSON200.ChoiceContext.ChoiceContextData) + if err != nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to convert choice context: %w", err) + } + + return types.CONTRACT_ID(resp.JSON200.FactoryId), choiceContext, disclosedContracts, nil +} diff --git a/eds/internal/api/tokenpool/factory/factory.go b/eds/internal/api/tokenpool/factory/factory.go new file mode 100644 index 000000000..bfae27d1a --- /dev/null +++ b/eds/internal/api/tokenpool/factory/factory.go @@ -0,0 +1,23 @@ +package factory + +import ( + "context" + + "github.com/smartcontractkit/chainlink-ccv/protocol" + "github.com/smartcontractkit/go-daml/pkg/types" + + "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/splice/splice_api_token_holding_v1" + "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/splice/splice_api_token_metadata_v1" + oapiCommon "github.com/smartcontractkit/chainlink-canton/openapi/gen/eds/common" +) + +type DisclosureFactory interface { + GetSendDisclosures(ctx context.Context, message oapiCommon.Message) (types.CONTRACT_ID, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) + GetExecuteDisclosures( + ctx context.Context, + message *protocol.Message, + instrumentId splice_api_token_holding_v1.InstrumentId, + inputHoldingCids []types.CONTRACT_ID, + receiver types.PARTY, + ) (types.CONTRACT_ID, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) +} diff --git a/eds/internal/api/tokenpool/factory/transferfactory.go b/eds/internal/api/tokenpool/factory/transferfactory.go new file mode 100644 index 000000000..e2d27359c --- /dev/null +++ b/eds/internal/api/tokenpool/factory/transferfactory.go @@ -0,0 +1,267 @@ +package factory + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/smartcontractkit/chainlink-ccv/protocol" + "github.com/smartcontractkit/go-daml/pkg/types" + + "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/splice/splice_api_token_holding_v1" + "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/splice/splice_api_token_metadata_v1" + "github.com/smartcontractkit/chainlink-canton/contracts" + "github.com/smartcontractkit/chainlink-canton/eds/config" + "github.com/smartcontractkit/chainlink-canton/eds/internal/api/converters" + "github.com/smartcontractkit/chainlink-canton/eds/internal/store" + oapiCommon "github.com/smartcontractkit/chainlink-canton/openapi/gen/eds/common" + "github.com/smartcontractkit/chainlink-canton/openapi/gen/transferInstructionV1" +) + +func NewTransferFactory(ctx context.Context, poolOwner types.PARTY, acs store.ActiveContractStoreInterface, cfg config.Factory) (DisclosureFactory, error) { + switch cfg.Type { + case config.FactoryTypeDisabled: + return nil, nil //nolint:nilnil + case config.FactoryTypeAddress: + factoryAddress := *cfg.InstanceAddress + + templateId, err := contracts.TemplateIDFromString(*cfg.TemplateId) + if err != nil { + return nil, fmt.Errorf("invalid TemplateId for TransferFactory: %w", err) + } + acs.RegisterTemplates(store.RegisteredTemplate{ + TemplateID: templateId, + PartyID: *cfg.Party, + }) + + return AddressTransferFactory{ + factoryAddress: factoryAddress, + acs: acs, + }, nil + case config.FactoryTypeURL: + // If authentication has been configured, add an interceptor that adds the Authorization header + var options []transferInstructionV1.ClientOption + if cfg.TokenStandardAuthConfig != nil { + authProvider, err := cfg.TokenStandardAuthConfig.NewProvider(ctx) + if err != nil { + return nil, fmt.Errorf("failed to create auth provider: %w", err) + } + // Try to get a token to validate the auth works + _, err = authProvider.TokenSource().Token() + if err != nil { + return nil, fmt.Errorf("failed to retrieve token: %w", err) + } + interceptor := func(ctx context.Context, req *http.Request) error { + token, err := authProvider.TokenSource().Token() + if err != nil { + return fmt.Errorf("failed to retrieve token: %w", err) + } + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken)) + + return nil + } + options = append(options, transferInstructionV1.WithRequestEditorFn(interceptor)) + } + transferInstructionClient, err := transferInstructionV1.NewClientWithResponses( + *cfg.TokenStandardURL, + options..., + ) + if err != nil { + return nil, fmt.Errorf("failed to create TransferInstructionV1 client with URL %q: %w", *cfg.TokenStandardURL, err) + } + + return URLTransferFactory{ + poolOwner: poolOwner, + transferInstructionClient: transferInstructionClient, + }, nil + case config.FactoryTypeURLRequests: + return nil, fmt.Errorf("invalid factory type %q: URLRequests is not supported for TransferFactory", cfg.Type) + } + + return nil, nil //nolint:nilnil +} + +type AddressTransferFactory struct { + factoryAddress contracts.InstanceAddress + acs store.ActiveContractStoreInterface +} + +func (f AddressTransferFactory) GetSendDisclosures(ctx context.Context, message oapiCommon.Message) (types.CONTRACT_ID, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { + activeTransferFactory, ok := f.acs.Get(f.factoryAddress) + if !ok { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("no active contract found for transfer factory at address %s", f.factoryAddress) + } + + return types.CONTRACT_ID(activeTransferFactory.GetCreatedEvent().GetContractId()), splice_api_token_metadata_v1.ChoiceContext{}, []oapiCommon.DisclosedContract{converters.ActiveContractToDisclosedContract(activeTransferFactory)}, nil +} + +func (f AddressTransferFactory) GetExecuteDisclosures( + ctx context.Context, + message *protocol.Message, + instrumentId splice_api_token_holding_v1.InstrumentId, + inputHoldingCids []types.CONTRACT_ID, + receiver types.PARTY, +) (types.CONTRACT_ID, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { + activeTransferFactory, ok := f.acs.Get(f.factoryAddress) + if !ok { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("no active contract found for transfer factory at address %s", f.factoryAddress) + } + + return types.CONTRACT_ID(activeTransferFactory.GetCreatedEvent().GetContractId()), splice_api_token_metadata_v1.ChoiceContext{}, []oapiCommon.DisclosedContract{converters.ActiveContractToDisclosedContract(activeTransferFactory)}, nil +} + +type URLTransferFactory struct { + poolOwner types.PARTY + transferInstructionClient transferInstructionV1.ClientWithResponsesInterface +} + +func (f URLTransferFactory) GetSendDisclosures(ctx context.Context, message oapiCommon.Message) (types.CONTRACT_ID, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { + if message.TokenTransfer == nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("no TokenTransfer in message") + } + tokenTransfer := message.TokenTransfer + instrumentId := tokenTransfer.Token + // API expects empty arrays to be `[]`, not `null` + inputHoldingCids := []string{} + if tokenTransfer.HoldingContractIds != nil { + inputHoldingCids = append(inputHoldingCids, *tokenTransfer.HoldingContractIds...) + } + + // TODO: for backward-compatibility, use poolOwner as sender if receiver is not specified + sender := f.poolOwner + if message.Sender != "" { + sender = types.PARTY(message.Sender) + } + + resp, err := f.transferInstructionClient.GetTransferFactoryWithResponse(ctx, transferInstructionV1.GetFactoryRequest{ + ChoiceArguments: map[string]any{ + "expectedAdmin": instrumentId.Admin, + "transfer": map[string]any{ + "sender": sender, + "receiver": f.poolOwner, + // TODO: this isn't currently used. If we'd wanted to take the amount from message.TokenTransfer it would have to be properly scaled by the TP's decimals + "amount": "1.0", + "instrumentId": map[string]any{ + "admin": instrumentId.Admin, + "id": instrumentId.Id, + }, + "lock": nil, + "requestedAt": time.Now().Add(time.Second * -10).Format(time.RFC3339), + "executeBefore": time.Now().Add(time.Hour * 24).Format(time.RFC3339), + "inputHoldingCids": inputHoldingCids, + "meta": map[string]any{ + "values": map[string]any{}, + }, + }, + "extraArgs": map[string]any{ + "context": map[string]any{ + "values": map[string]any{}, + }, + "meta": map[string]any{ + "values": map[string]any{}, + }, + }, + }, + ExcludeDebugFields: nil, + }) + if err != nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to call GetTransferFactory: %w", err) + } + if resp.StatusCode() != http.StatusOK { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("unexpected status code: %d; response: %s", resp.StatusCode(), string(resp.Body)) + } + + disclosedContracts := make([]oapiCommon.DisclosedContract, len(resp.JSON200.ChoiceContext.DisclosedContracts)) + for i, contract := range resp.JSON200.ChoiceContext.DisclosedContracts { + disclosedContracts[i] = oapiCommon.DisclosedContract{ + TemplateId: contract.TemplateId, + ContractId: contract.ContractId, + CreatedEventBlob: contract.CreatedEventBlob, + SynchronizerId: contract.SynchronizerId, + } + } + + choiceContext, err := contracts.ChoiceContextFromData(resp.JSON200.ChoiceContext.ChoiceContextData) + if err != nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to convert choice context: %w", err) + } + + return types.CONTRACT_ID(resp.JSON200.FactoryId), choiceContext, disclosedContracts, nil +} + +func (f URLTransferFactory) GetExecuteDisclosures( + ctx context.Context, + message *protocol.Message, + instrumentId splice_api_token_holding_v1.InstrumentId, + inputHoldingCids []types.CONTRACT_ID, + receiver types.PARTY, +) (types.CONTRACT_ID, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { + if message.TokenTransfer == nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("no TokenTransfer in message") + } + // API expects empty arrays to be `[]`, not `null` + if inputHoldingCids == nil { + inputHoldingCids = []types.CONTRACT_ID{} + } + + // TODO: for backward-compatibility, use poolOwner as receiver if not specified + if receiver == "" { + receiver = f.poolOwner + } + + resp, err := f.transferInstructionClient.GetTransferFactoryWithResponse(ctx, transferInstructionV1.GetFactoryRequest{ + ChoiceArguments: map[string]any{ + "expectedAdmin": instrumentId.Admin, + "transfer": map[string]any{ + "sender": f.poolOwner, + "receiver": receiver, + // TODO: this isn't currently used. If we'd wanted to take the amount from message.TokenTransfer it would have to be properly scaled by the TP's decimals + "amount": "1.0", + "instrumentId": map[string]any{ + "admin": instrumentId.Admin, + "id": instrumentId.Id, + }, + "lock": nil, + "requestedAt": time.Now().Add(time.Second * -10).Format(time.RFC3339), + "executeBefore": time.Now().Add(time.Hour * 24).Format(time.RFC3339), + "inputHoldingCids": inputHoldingCids, + "meta": map[string]any{ + "values": map[string]any{}, + }, + }, + "extraArgs": map[string]any{ + "context": map[string]any{ + "values": map[string]any{}, + }, + "meta": map[string]any{ + "values": map[string]any{}, + }, + }, + }, + ExcludeDebugFields: nil, + }) + if err != nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to call GetTransferFactory: %w", err) + } + if resp.StatusCode() != http.StatusOK { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("unexpected status code: %d; response: %s", resp.StatusCode(), string(resp.Body)) + } + + disclosedContracts := make([]oapiCommon.DisclosedContract, len(resp.JSON200.ChoiceContext.DisclosedContracts)) + for i, contract := range resp.JSON200.ChoiceContext.DisclosedContracts { + disclosedContracts[i] = oapiCommon.DisclosedContract{ + TemplateId: contract.TemplateId, + ContractId: contract.ContractId, + CreatedEventBlob: contract.CreatedEventBlob, + SynchronizerId: contract.SynchronizerId, + } + } + + choiceContext, err := contracts.ChoiceContextFromData(resp.JSON200.ChoiceContext.ChoiceContextData) + if err != nil { + return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to convert choice context: %w", err) + } + + return types.CONTRACT_ID(resp.JSON200.FactoryId), choiceContext, disclosedContracts, nil +} diff --git a/eds/internal/api/tokenpool/token_standard.go b/eds/internal/api/tokenpool/token_standard.go deleted file mode 100644 index 402864cc9..000000000 --- a/eds/internal/api/tokenpool/token_standard.go +++ /dev/null @@ -1,279 +0,0 @@ -package tokenpool - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "io" - "net/http" - "time" - - "github.com/smartcontractkit/go-daml/pkg/types" - - "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/splice/splice_api_token_holding_v1" - "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/splice/splice_api_token_metadata_v1" - "github.com/smartcontractkit/chainlink-canton/contracts" - "github.com/smartcontractkit/chainlink-canton/eds/config" - "github.com/smartcontractkit/chainlink-canton/eds/internal/api/converters" - "github.com/smartcontractkit/chainlink-canton/eds/internal/store" - oapiCommon "github.com/smartcontractkit/chainlink-canton/openapi/gen/eds/common" - "github.com/smartcontractkit/chainlink-canton/openapi/gen/transferInstructionV1" -) - -type transferFactory func(ctx context.Context, instrumentId splice_api_token_holding_v1.InstrumentId) (string, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) - -func getTransferFactory(ctx context.Context, poolOwner types.PARTY, acs store.ActiveContractStoreInterface, cfg config.TransferFactory) (transferFactory, error) { - switch cfg.Type { - case config.FactoryTypeDisabled: - return nil, nil //nolint:nilnil - case config.FactoryTypeAddress: - factoryAddress := *cfg.InstanceAddress - - templateId, err := contracts.TemplateIDFromString(*cfg.TemplateId) - if err != nil { - return nil, fmt.Errorf("invalid TemplateId for TransferPreapproval: %w", err) - } - acs.RegisterTemplates(store.RegisteredTemplate{ - TemplateID: templateId, - PartyID: *cfg.Party, - }) - - return func(ctx context.Context, instrumentId splice_api_token_holding_v1.InstrumentId) (string, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { - activeTransferFactory, ok := acs.Get(factoryAddress) - if !ok { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("no active contract found for transfer factory at address %s", factoryAddress) - } - - return activeTransferFactory.GetCreatedEvent().GetContractId(), splice_api_token_metadata_v1.ChoiceContext{}, []oapiCommon.DisclosedContract{converters.ActiveContractToDisclosedContract(activeTransferFactory)}, nil - }, nil - case config.FactoryTypeURL: - // If authentication has been configured, add an interceptor that adds the Authorization header - var options []transferInstructionV1.ClientOption - if cfg.TokenStandardAuthConfig != nil { - authProvider, err := cfg.TokenStandardAuthConfig.NewProvider(ctx) - if err != nil { - return nil, fmt.Errorf("failed to create auth provider: %w", err) - } - interceptor := func(ctx context.Context, req *http.Request) error { - token, err := authProvider.TokenSource().Token() - if err != nil { - return fmt.Errorf("failed to retrieve token: %w", err) - } - req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken)) - - return nil - } - options = append(options, transferInstructionV1.WithRequestEditorFn(interceptor)) - } - transferInstructionClient, err := transferInstructionV1.NewClientWithResponses( - *cfg.TokenStandardURL, - options..., - ) - if err != nil { - return nil, fmt.Errorf("failed to create TransferInstructionV1 client with URL %q: %w", *cfg.TokenStandardURL, err) - } - - return func(ctx context.Context, instrumentId splice_api_token_holding_v1.InstrumentId) (string, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { - resp, err := transferInstructionClient.GetTransferFactoryWithResponse(ctx, transferInstructionV1.GetFactoryRequest{ - ChoiceArguments: map[string]any{ - "expectedAdmin": instrumentId.Admin, - "transfer": map[string]any{ - "sender": poolOwner, - "receiver": poolOwner, - "amount": "1.0", - "instrumentId": map[string]any{ - "admin": instrumentId.Admin, - "id": instrumentId.Id, - }, - "lock": nil, - "requestedAt": time.Now().Add(time.Second * -10).Format(time.RFC3339), - "executeBefore": time.Now().Add(time.Hour * 24).Format(time.RFC3339), - "inputHoldingCids": []string{}, - "meta": map[string]any{ - "values": map[string]any{}, - }, - }, - "extraArgs": map[string]any{ - "context": map[string]any{ - "values": map[string]any{}, - }, - "meta": map[string]any{ - "values": map[string]any{}, - }, - }, - }, - ExcludeDebugFields: nil, - }) - if err != nil { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to call GetTransferFactory: %w", err) - } - if resp.StatusCode() != http.StatusOK { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("unexpected status code: %d; response: %s", resp.StatusCode(), string(resp.Body)) - } - - disclosedContracts := make([]oapiCommon.DisclosedContract, len(resp.JSON200.ChoiceContext.DisclosedContracts)) - for i, contract := range resp.JSON200.ChoiceContext.DisclosedContracts { - disclosedContracts[i] = oapiCommon.DisclosedContract{ - TemplateId: contract.TemplateId, - ContractId: contract.ContractId, - CreatedEventBlob: contract.CreatedEventBlob, - SynchronizerId: contract.SynchronizerId, - } - } - - choiceContext, err := contracts.ChoiceContextFromData(resp.JSON200.ChoiceContext.ChoiceContextData) - if err != nil { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to convert choice context: %w", err) - } - - return resp.JSON200.FactoryId, choiceContext, disclosedContracts, nil - }, nil - } - - return nil, nil //nolint:nilnil -} - -type burnMintFactory func(ctx context.Context, instrumentId splice_api_token_holding_v1.InstrumentId) (string, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) - -func getBurnMintFactory(ctx context.Context, acs store.ActiveContractStoreInterface, cfg config.BurnMintFactory) (burnMintFactory, error) { - switch cfg.Type { - case config.FactoryTypeDisabled: - return nil, nil //nolint:nilnil - case config.FactoryTypeAddress: - factoryAddress := *cfg.InstanceAddress - - templateId, err := contracts.TemplateIDFromString(*cfg.TemplateId) - if err != nil { - return nil, fmt.Errorf("invalid TemplateId for TransferPreapproval: %w", err) - } - acs.RegisterTemplates(store.RegisteredTemplate{ - TemplateID: templateId, - PartyID: *cfg.Party, - }) - - return func(ctx context.Context, _ splice_api_token_holding_v1.InstrumentId) (string, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { - activeTransferFactory, ok := acs.Get(factoryAddress) - if !ok { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("no active contract found for transfer factory at address %s", factoryAddress) - } - - return activeTransferFactory.GetCreatedEvent().GetContractId(), splice_api_token_metadata_v1.ChoiceContext{}, []oapiCommon.DisclosedContract{converters.ActiveContractToDisclosedContract(activeTransferFactory)}, nil - }, nil - case config.FactoryTypeURL: - // DA utility-registry factory resolution endpoint (e.g. /mint/v0/request): - // POST {TokenStandardURL} (URL is fully configured, including path) - // Request: { holder, instrumentId } (mint endpoint shape) - // Response: FactoryWithChoiceContext { factoryId, choiceContext.{choiceContextData, disclosedContracts} } - // - // We use the /mint/v0/request endpoint because DA's /burn-mint-factory endpoint - // currently has a bug where issuer-credentials is returned as [] while - // /mint/v0/request correctly populates them. Both endpoints return the same - // factoryId (AllocationFactory) and the same context keys that - // AllocationFactory_InternalBurnMint reads (instrument-configuration + - // issuer-credentials). The mint endpoint is read-only — it does not actually - // mint; it returns the factory + context needed to later exercise the choice. - // Revisit this when DA fixes the /burn-mint-factory endpoint to populate - // issuer-credentials directly. - // - // Auth is optional via TokenStandardAuthConfig (DA's public endpoints have security: []). - httpClient := &http.Client{} - - var requestEditor transferInstructionV1.RequestEditorFn - if cfg.TokenStandardAuthConfig != nil { - authProvider, err := cfg.TokenStandardAuthConfig.NewProvider(ctx) - if err != nil { - return nil, fmt.Errorf("failed to create auth provider for BurnMintFactory: %w", err) - } - requestEditor = func(ctx context.Context, req *http.Request) error { - token, err := authProvider.TokenSource().Token() - if err != nil { - return fmt.Errorf("failed to retrieve token: %w", err) - } - req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken)) - - return nil - } - } - - factoryURL := *cfg.TokenStandardURL - - return func(ctx context.Context, instrumentId splice_api_token_holding_v1.InstrumentId) (string, splice_api_token_metadata_v1.ChoiceContext, []oapiCommon.DisclosedContract, error) { - // DA's mint request body shape: { holder, instrumentId }. - // holder is required by the schema but the backend does not use it for - // factory/context resolution — the choiceContext is keyed by instrumentId. - // Send instrumentId.admin as a dummy holder (same party, harmless). - requestBody := map[string]any{ - "holder": instrumentId.Admin, - "instrumentId": map[string]any{ - "admin": instrumentId.Admin, - "id": instrumentId.Id, - }, - } - bodyBytes, err := json.Marshal(requestBody) - if err != nil { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to marshal BurnMintFactory request: %w", err) - } - - req, err := http.NewRequestWithContext(ctx, http.MethodPost, factoryURL, bytes.NewReader(bodyBytes)) - if err != nil { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to create BurnMintFactory request: %w", err) - } - req.Header.Set("Content-Type", "application/json") - if requestEditor != nil { - if err := requestEditor(ctx, req); err != nil { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to apply auth to BurnMintFactory request: %w", err) - } - } - - resp, err := httpClient.Do(req) - if err != nil { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to call BurnMintFactory endpoint %q: %w", factoryURL, err) - } - defer resp.Body.Close() - - respBytes, err := io.ReadAll(resp.Body) - if err != nil { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to read BurnMintFactory response: %w", err) - } - if resp.StatusCode != http.StatusOK { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("BurnMintFactory endpoint %q returned status %d: %s", factoryURL, resp.StatusCode, string(respBytes)) - } - - var factoryResp struct { - FactoryId string `json:"factoryId"` - ChoiceContext struct { - ChoiceContextData map[string]any `json:"choiceContextData"` - DisclosedContracts []struct { - TemplateId string `json:"templateId"` - ContractId string `json:"contractId"` - CreatedEventBlob string `json:"createdEventBlob"` - SynchronizerId string `json:"synchronizerId"` - } `json:"disclosedContracts"` - } `json:"choiceContext"` - } - if err := json.Unmarshal(respBytes, &factoryResp); err != nil { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to parse BurnMintFactory response: %w", err) - } - - disclosedContracts := make([]oapiCommon.DisclosedContract, len(factoryResp.ChoiceContext.DisclosedContracts)) - for i, c := range factoryResp.ChoiceContext.DisclosedContracts { - disclosedContracts[i] = oapiCommon.DisclosedContract{ - TemplateId: c.TemplateId, - ContractId: c.ContractId, - CreatedEventBlob: c.CreatedEventBlob, - SynchronizerId: c.SynchronizerId, - } - } - - choiceContext, err := contracts.ChoiceContextFromData(factoryResp.ChoiceContext.ChoiceContextData) - if err != nil { - return "", splice_api_token_metadata_v1.ChoiceContext{}, nil, fmt.Errorf("failed to convert BurnMintFactory choice context: %w", err) - } - - return factoryResp.FactoryId, choiceContext, disclosedContracts, nil - }, nil - } - - return nil, nil //nolint:nilnil -} diff --git a/eds/internal/api/tokenpool/tokenpool.go b/eds/internal/api/tokenpool/tokenpool.go index 7ce68aaa1..5a8e087b8 100644 --- a/eds/internal/api/tokenpool/tokenpool.go +++ b/eds/internal/api/tokenpool/tokenpool.go @@ -27,17 +27,17 @@ import ( "github.com/smartcontractkit/chainlink-canton/eds/config" "github.com/smartcontractkit/chainlink-canton/eds/internal/api/converters" "github.com/smartcontractkit/chainlink-canton/eds/internal/api/global" + "github.com/smartcontractkit/chainlink-canton/eds/internal/api/tokenpool/factory" "github.com/smartcontractkit/chainlink-canton/eds/internal/store" oapiCommon "github.com/smartcontractkit/chainlink-canton/openapi/gen/eds/common" oapiTokenPool "github.com/smartcontractkit/chainlink-canton/openapi/gen/eds/tokenpool" ) type ContractConfig struct { - Type config.TokenPoolType - Owner types.PARTY - transferFactory transferFactory - burnMintFactory burnMintFactory - preapproval preapprovalFactory + Type config.TokenPoolType + Owner types.PARTY + disclosureFactory factory.DisclosureFactory + preapproval preapprovalFactory } type Server struct { @@ -86,24 +86,24 @@ func NewServer( // If the TransferFactory is configured, this will make this API automatically retrieve the necessary // ContractIds, Context, and disclosures from the instrument's TransferFactory. // If not enabled, users will have to get these information from the TransferFactory API themselves. - if tokenPool.TransferFactory != nil { - getFactoryFunc, err := getTransferFactory(ctx, types.PARTY(tokenPool.PoolOwner), activeContractStore, *tokenPool.TransferFactory) + if tokenPool.Factory != nil { + disclosureFactory, err := factory.NewTransferFactory(ctx, types.PARTY(tokenPool.PoolOwner), activeContractStore, *tokenPool.Factory) if err != nil { return nil, fmt.Errorf("failed to get transfer factory for token pool with address %s: %w", tokenPool.InstanceAddress, err) } - contractConfig.transferFactory = getFactoryFunc + contractConfig.disclosureFactory = disclosureFactory } case config.TokenPoolTypeBurnMint: s.activeContractStore.RegisterTemplates(store.RegisteredTemplate{ TemplateID: contracts.TemplateIDFromBinding(burnminttokenpool.BurnMintTokenPool{}), PartyID: tokenPool.PartyID, }) - if tokenPool.BurnMintFactory != nil { - getFactoryFunc, err := getBurnMintFactory(ctx, activeContractStore, *tokenPool.BurnMintFactory) + if tokenPool.Factory != nil { + disclosureFactory, err := factory.NewBurnMintFactory(ctx, types.PARTY(tokenPool.PoolOwner), activeContractStore, *tokenPool.Factory) if err != nil { return nil, fmt.Errorf("failed to get burn mint factory for token pool with address %s: %w", tokenPool.InstanceAddress, err) } - contractConfig.burnMintFactory = getFactoryFunc + contractConfig.disclosureFactory = disclosureFactory } default: return nil, fmt.Errorf("unsupported token pool type: %s", tokenPool.Type) @@ -241,15 +241,15 @@ func (s Server) lockReleaseTokenPoolSend( } var factoryDisclosures []oapiCommon.DisclosedContract // Get ExtraArgs and TransferFactory from Token Standard API (if enabled) - if cfg.transferFactory != nil { - transferFactory, transferContext, disclosedFactoryContracts, err := cfg.transferFactory(c, lockReleaseTokenPool.InstrumentId) + if cfg.disclosureFactory != nil { + transferFactory, transferContext, disclosedFactoryContracts, err := cfg.disclosureFactory.GetSendDisclosures(c, message) if err != nil { s.logger.Error().Err(err).Msg("transfer factory returned an error") c.AbortWithStatusJSON(http.StatusInternalServerError, oapiCommon.ErrorResponse{Error: "internal server error"}) return } choiceContext.Values[string(lockreleasetokenpool.TransferFactoryContextKey)] = splice_api_token_metadata_v1.AnyValue{ - AVContractId: new(types.CONTRACT_ID(transferFactory)), + AVContractId: new(transferFactory), } transferFactoryContext.Values = transferContext.Values factoryDisclosures = append(factoryDisclosures, disclosedFactoryContracts...) @@ -354,15 +354,15 @@ func (s Server) burnMintTokenPoolSend( // Get BurnMintFactory (if enabled) var factoryDisclosures []oapiCommon.DisclosedContract - if cfg.burnMintFactory != nil { - factoryId, factoryCtx, disclosedFactoryContracts, err := cfg.burnMintFactory(c, burnMintTokenPool.InstrumentId) + if cfg.disclosureFactory != nil { + factoryId, factoryCtx, disclosedFactoryContracts, err := cfg.disclosureFactory.GetSendDisclosures(c, message) if err != nil { s.logger.Error().Err(err).Msg("burn mint factory returned an error") c.AbortWithStatusJSON(http.StatusInternalServerError, oapiCommon.ErrorResponse{Error: "internal server error"}) return } choiceContext.Values[string(burnminttokenpool.BurnMintFactoryContextKey)] = splice_api_token_metadata_v1.AnyValue{ - AVContractId: new(types.CONTRACT_ID(factoryId)), + AVContractId: new(factoryId), } factoryDisclosures = append(factoryDisclosures, disclosedFactoryContracts...) // Merge factory-returned context (e.g. issuer credentials) into the extra-args context @@ -461,10 +461,10 @@ func (s Server) PostTokenPoolExecute(c *gin.Context, address string) { switch cfg.Type { case config.TokenPoolTypeLockRelease: - s.lockReleaseTokenPoolExecute(c, cfg, instanceAddress, activeTokenPoolContract, sourceChainSelector, message) + s.lockReleaseTokenPoolExecute(c, cfg, instanceAddress, activeTokenPoolContract, sourceChainSelector, message, types.PARTY(req.Receiver)) return case config.TokenPoolTypeBurnMint: - s.burnMintTokenPoolExecute(c, cfg, instanceAddress, activeTokenPoolContract, sourceChainSelector, message) + s.burnMintTokenPoolExecute(c, cfg, instanceAddress, activeTokenPoolContract, sourceChainSelector, message, types.PARTY(req.Receiver)) return default: s.logger.Error().Stringer("address", instanceAddress).Msgf("unknown token pool type: %s", cfg.Type) @@ -480,6 +480,7 @@ func (s Server) lockReleaseTokenPoolExecute( activeTokenPoolContract *apiv2.ActiveContract, sourceChainSelector uint64, message *protocol.Message, + receiver types.PARTY, ) { lockReleaseTokenPool, err := ParseLockReleaseTokenPool(activeTokenPoolContract.CreatedEvent) if err != nil { @@ -530,9 +531,11 @@ func (s Server) lockReleaseTokenPoolExecute( c.AbortWithStatusJSON(http.StatusInternalServerError, oapiCommon.ErrorResponse{Error: "internal server error"}) return } + inputHoldingCids := make([]types.CONTRACT_ID, len(holdings)) tokenPoolHoldings := make([]splice_api_token_metadata_v1.AnyValue, len(holdings)) disclosedHoldings := make([]oapiCommon.DisclosedContract, len(holdings)) for i, holding := range holdings { + inputHoldingCids[i] = types.CONTRACT_ID(holding.GetCreatedEvent().GetContractId()) tokenPoolHoldings[i] = splice_api_token_metadata_v1.AnyValue{AVContractId: new(types.CONTRACT_ID(holding.GetCreatedEvent().GetContractId()))} disclosedHoldings[i] = converters.ActiveContractToDisclosedContract(holding) } @@ -549,15 +552,15 @@ func (s Server) lockReleaseTokenPoolExecute( } var factoryDisclosures []oapiCommon.DisclosedContract // Get ExtraArgs and TransferFactory from Token Standard API (if enabled) - if cfg.transferFactory != nil { - transferFactory, transferContext, disclosedFactoryContracts, err := cfg.transferFactory(c, lockReleaseTokenPool.InstrumentId) + if cfg.disclosureFactory != nil { + transferFactory, transferContext, disclosedFactoryContracts, err := cfg.disclosureFactory.GetExecuteDisclosures(c, message, lockReleaseTokenPool.InstrumentId, inputHoldingCids, receiver) if err != nil { s.logger.Error().Err(err).Msg("transfer factory returned an error") c.AbortWithStatusJSON(http.StatusInternalServerError, oapiCommon.ErrorResponse{Error: "internal server error"}) return } choiceContext.Values[string(lockreleasetokenpool.TransferFactoryContextKey)] = splice_api_token_metadata_v1.AnyValue{ - AVContractId: new(types.CONTRACT_ID(transferFactory)), + AVContractId: new(transferFactory), } transferFactoryContext.Values = transferContext.Values factoryDisclosures = append(factoryDisclosures, disclosedFactoryContracts...) @@ -603,6 +606,7 @@ func (s Server) burnMintTokenPoolExecute( activeTokenPoolContract *apiv2.ActiveContract, sourceChainSelector uint64, message *protocol.Message, + receiver types.PARTY, ) { burnMintTokenPool, err := ParseBurnMintTokenPool(activeTokenPoolContract.CreatedEvent) if err != nil { @@ -659,15 +663,15 @@ func (s Server) burnMintTokenPoolExecute( // Get BurnMintFactory (if enabled) var factoryDisclosures []oapiCommon.DisclosedContract - if cfg.burnMintFactory != nil { - factoryId, factoryCtx, disclosedFactoryContracts, err := cfg.burnMintFactory(c, burnMintTokenPool.InstrumentId) + if cfg.disclosureFactory != nil { + factoryId, factoryCtx, disclosedFactoryContracts, err := cfg.disclosureFactory.GetExecuteDisclosures(c, message, burnMintTokenPool.InstrumentId, nil, receiver) if err != nil { s.logger.Error().Err(err).Msg("burn mint factory returned an error") c.AbortWithStatusJSON(http.StatusInternalServerError, oapiCommon.ErrorResponse{Error: "internal server error"}) return } choiceContext.Values[string(burnminttokenpool.BurnMintFactoryContextKey)] = splice_api_token_metadata_v1.AnyValue{ - AVContractId: new(types.CONTRACT_ID(factoryId)), + AVContractId: new(factoryId), } factoryDisclosures = append(factoryDisclosures, disclosedFactoryContracts...) // Merge factory-returned context (e.g. issuer credentials) into the extra-args context diff --git a/examples/cli/cmd/canton.go b/examples/cli/cmd/canton.go index 93c0dacc0..8913c335d 100644 --- a/examples/cli/cmd/canton.go +++ b/examples/cli/cmd/canton.go @@ -452,11 +452,12 @@ func cantonExecute(ctx context.Context, b *clients.Bundle, vr protocol.VerifierR return fmt.Errorf("parse VerifierDestAddress: %w", err) } - ccipExecuteDisclosure, err := eds.GetCCIPExecuteDisclosure(ctx, b.CCIPEDS, encodedHex) + receiverParty := types.PARTY(b.Participant.PartyID) + ccipExecuteDisclosure, err := eds.GetCCIPExecuteDisclosure(ctx, b.CCIPEDS, encodedHex, receiverParty) if err != nil { return fmt.Errorf("CCIP execute disclosure: %w", err) } - ccvExecuteDisclosure, err := eds.GetCCVExecuteDisclosure(ctx, b.CCVEDS, encodedHex, verifierRawAddress.InstanceAddress()) + ccvExecuteDisclosure, err := eds.GetCCVExecuteDisclosure(ctx, b.CCVEDS, encodedHex, verifierRawAddress.InstanceAddress(), receiverParty) if err != nil { return fmt.Errorf("CCV execute disclosure: %w", err) } @@ -483,7 +484,7 @@ func cantonExecute(ctx context.Context, b *clients.Bundle, vr protocol.VerifierR if err != nil { return fmt.Errorf("get token pool: %w", err) } - tokenPoolExecuteDisclosure, err := eds.GetTokenPoolExecuteDisclosure(ctx, b.TokenPoolEDS, encodedHex, tokenPoolAddress.InstanceAddress()) + tokenPoolExecuteDisclosure, err := eds.GetTokenPoolExecuteDisclosure(ctx, b.TokenPoolEDS, encodedHex, tokenPoolAddress.InstanceAddress(), receiverParty) if err != nil { return fmt.Errorf("token pool execute disclosure: %w", err) } @@ -522,7 +523,7 @@ func cantonExecute(ctx context.Context, b *clients.Bundle, vr protocol.VerifierR ChoiceArgument: ledger.MapToValue(executeArgs), }}, }}, - ActAs: []string{b.Participant.PartyID}, + ActAs: []string{string(receiverParty)}, DisclosedContracts: allDisclosures, }, }) @@ -747,8 +748,13 @@ func cantonSend( }, GasLimit: gasLimit, Payload: hex.EncodeToString(payload), + Sender: b.Participant.PartyID, Receiver: hex.EncodeToString(receiver.Bytes()), } + tokenTransferHoldings := make([]string, len(tokenTransferInputCids)) + for i, cid := range tokenTransferInputCids { + tokenTransferHoldings[i] = string(cid) + } if withToken { msg.TokenTransfer = &oapiCommon.TokenTransfer{ Amount: normalizedAmount, @@ -756,6 +762,7 @@ func cantonSend( Admin: oapiCommon.PartyId(linkInstrumentId.Admin), Id: string(linkInstrumentId.Id), }, + HoldingContractIds: new(tokenTransferHoldings), } } diff --git a/integration-tests/ccip/ccip_execute_test.go b/integration-tests/ccip/ccip_execute_test.go index 0b079c628..ca0609a9a 100644 --- a/integration-tests/ccip/ccip_execute_test.go +++ b/integration-tests/ccip/ccip_execute_test.go @@ -527,9 +527,9 @@ func TestCCIPExecuteE2E(t *testing.T) { // Get disclosures for CCIPReceiver.Execute. The execute submission itself stays // receiver-only; ccip-owned dependencies are only provided via disclosure. - ccipExecuteDisclosure, err := edsTesthelpers.GetCCIPExecuteDisclosure(t.Context(), ccipAPIClient, encodedMessageHex) + ccipExecuteDisclosure, err := edsTesthelpers.GetCCIPExecuteDisclosure(t.Context(), ccipAPIClient, encodedMessageHex, types.PARTY(partyReceiver)) require.NoError(t, err) - ccvExecuteDisclosure, err := edsTesthelpers.GetCCVExecuteDisclosure(t.Context(), ccvAPIClient, encodedMessageHex, committeeVerifierAddress.InstanceAddress()) + ccvExecuteDisclosure, err := edsTesthelpers.GetCCVExecuteDisclosure(t.Context(), ccvAPIClient, encodedMessageHex, committeeVerifierAddress.InstanceAddress(), types.PARTY(partyReceiver)) require.NoError(t, err) executeArgs := receiver.Execute{ diff --git a/integration-tests/ccip/ccip_execute_token_bnm_test.go b/integration-tests/ccip/ccip_execute_token_bnm_test.go index 0855f5e3d..cb977bdb1 100644 --- a/integration-tests/ccip/ccip_execute_token_bnm_test.go +++ b/integration-tests/ccip/ccip_execute_token_bnm_test.go @@ -530,7 +530,7 @@ func runBnMTokenPoolReceiveFlowTest(t *testing.T, tc bnmTokenPoolReceiveFlowTest }, PoolOwner: partyCCIP, // By setting the TokenStandard info, the Token Pool API will return the necessary factory disclosures - BurnMintFactory: &config.BurnMintFactory{ + Factory: &config.Factory{ Type: config.FactoryTypeAddress, TemplateId: new(link.LinkRegistry{}.GetTemplateID()), Party: new(partyTokenPoolOwner), @@ -669,11 +669,11 @@ func runBnMTokenPoolReceiveFlowTest(t *testing.T, tc bnmTokenPoolReceiveFlowTest tokenPoolAddressEDS, err := edsTesthelpers.GetTokenPoolForToken(t.Context(), ccipAPIClient, hashedLinkInstrumentId) require.NoError(t, err) - ccipExecuteDisclosure, err := edsTesthelpers.GetCCIPExecuteDisclosure(t.Context(), ccipAPIClient, encodedMessageHex) + ccipExecuteDisclosure, err := edsTesthelpers.GetCCIPExecuteDisclosure(t.Context(), ccipAPIClient, encodedMessageHex, types.PARTY(partyReceiver)) require.NoError(t, err) - ccvExecuteDisclosure, err := edsTesthelpers.GetCCVExecuteDisclosure(t.Context(), ccvAPIClient, encodedMessageHex, committeeVerifierAddress.InstanceAddress()) + ccvExecuteDisclosure, err := edsTesthelpers.GetCCVExecuteDisclosure(t.Context(), ccvAPIClient, encodedMessageHex, committeeVerifierAddress.InstanceAddress(), types.PARTY(partyReceiver)) require.NoError(t, err) - tokenPoolDisclosure, err := edsTesthelpers.GetTokenPoolExecuteDisclosure(t.Context(), tokenPoolAPIClient, encodedMessageHex, tokenPoolAddressEDS.InstanceAddress()) + tokenPoolDisclosure, err := edsTesthelpers.GetTokenPoolExecuteDisclosure(t.Context(), tokenPoolAPIClient, encodedMessageHex, tokenPoolAddressEDS.InstanceAddress(), types.PARTY(partyReceiver)) require.NoError(t, err) executeArgs := receiver.Execute{ diff --git a/integration-tests/ccip/ccip_execute_token_lnr_test.go b/integration-tests/ccip/ccip_execute_token_lnr_test.go index a51745f87..92b5c5d14 100644 --- a/integration-tests/ccip/ccip_execute_token_lnr_test.go +++ b/integration-tests/ccip/ccip_execute_token_lnr_test.go @@ -545,7 +545,7 @@ func runLnRTokenPoolReceiveFlowTest(t *testing.T, tc lnrTokenPoolReceiveFlowTest }, PoolOwner: partyCCIP, // By setting the TokenStandard info, the Token Pool API will return the necessary factory disclosures - TransferFactory: &config.TransferFactory{ + Factory: &config.Factory{ Type: config.FactoryTypeURL, TokenStandardURL: new(fmt.Sprintf("%s/v0/scan-proxy", ccipParticipant.Endpoints.ValidatorAPIURL)), TokenStandardAuthConfig: &commonconfig.AuthConfig{ @@ -686,11 +686,11 @@ func runLnRTokenPoolReceiveFlowTest(t *testing.T, tc lnrTokenPoolReceiveFlowTest tokenPoolAddressEDS, err := edsTesthelpers.GetTokenPoolForToken(t.Context(), ccipAPIClient, hashedInstrumentId) require.NoError(t, err) - ccipExecuteDisclosure, err := edsTesthelpers.GetCCIPExecuteDisclosure(t.Context(), ccipAPIClient, encodedMessageHex) + ccipExecuteDisclosure, err := edsTesthelpers.GetCCIPExecuteDisclosure(t.Context(), ccipAPIClient, encodedMessageHex, types.PARTY(partyReceiver)) require.NoError(t, err) - ccvExecuteDisclosure, err := edsTesthelpers.GetCCVExecuteDisclosure(t.Context(), ccvAPIClient, encodedMessageHex, committeeVerifierAddress.InstanceAddress()) + ccvExecuteDisclosure, err := edsTesthelpers.GetCCVExecuteDisclosure(t.Context(), ccvAPIClient, encodedMessageHex, committeeVerifierAddress.InstanceAddress(), types.PARTY(partyReceiver)) require.NoError(t, err) - tokenPoolDisclosure, err := edsTesthelpers.GetTokenPoolExecuteDisclosure(t.Context(), tokenPoolAPIClient, encodedMessageHex, tokenPoolAddressEDS.InstanceAddress()) + tokenPoolDisclosure, err := edsTesthelpers.GetTokenPoolExecuteDisclosure(t.Context(), tokenPoolAPIClient, encodedMessageHex, tokenPoolAddressEDS.InstanceAddress(), types.PARTY(partyReceiver)) require.NoError(t, err) executeArgs := receiver.Execute{ diff --git a/integration-tests/ccip/ccip_send_test.go b/integration-tests/ccip/ccip_send_test.go index 085689504..b9a4b5018 100644 --- a/integration-tests/ccip/ccip_send_test.go +++ b/integration-tests/ccip/ccip_send_test.go @@ -477,7 +477,7 @@ func TestCCIPSend(t *testing.T) { disclosedRouter, err := testhelpers.GetDisclosedContractByTemplateId(t.Context(), senderParticipant, contracts.IdentifierFromBinding(ccipruntime.PerPartyRouter{})) require.NoError(t, err) - // Prepare receiver address (destination party encoded as keccak256) + // Prepare EVM receiver address receiver := hexutil.MustDecode("0xcf8def9adfe3dd90b3dffe42c8eabbf7cd4ee6ca") receiverHex := hex.EncodeToString(receiver) @@ -564,8 +564,9 @@ func TestCCIPSend(t *testing.T) { Admin: oapiCommon.PartyId(nativeInstrumentId.Admin), Id: string(nativeInstrumentId.Id), }, - Payload: "", - Receiver: "", + Payload: testPayloadHex, + Sender: partySender, + Receiver: receiverHex, GasLimit: 100_000, TokenTransfer: nil, } diff --git a/integration-tests/ccip/ccip_send_with_token_bnm_test.go b/integration-tests/ccip/ccip_send_with_token_bnm_test.go index 0bca4afe4..1a48d8468 100644 --- a/integration-tests/ccip/ccip_send_with_token_bnm_test.go +++ b/integration-tests/ccip/ccip_send_with_token_bnm_test.go @@ -593,7 +593,7 @@ func TestBnMTokenPool_FullSendFlow(t *testing.T) { InstanceAddress: tokenPoolAddress.InstanceAddress(), }, PoolOwner: partySender, - BurnMintFactory: &config.BurnMintFactory{ + Factory: &config.Factory{ Type: config.FactoryTypeAddress, TemplateId: new(link.LinkRegistry{}.GetTemplateID()), Party: new(partySender), @@ -689,7 +689,7 @@ func TestBnMTokenPool_FullSendFlow(t *testing.T) { ccipSenderCid := extractCreatedContractId(res) t.Logf("Deployed CCIPSender: %s", ccipSenderCid) - // Prepare receiver address (destination party encoded as keccak256) + // Prepare EVM receiver address receiver := hexutil.MustDecode("0xcf8def9adfe3dd90b3dffe42c8eabbf7cd4ee6ca") receiverHex := hex.EncodeToString(receiver) @@ -806,8 +806,9 @@ func TestBnMTokenPool_FullSendFlow(t *testing.T) { Admin: oapiCommon.PartyId(nativeInstrumentId.Admin), Id: string(nativeInstrumentId.Id), }, - Payload: "", - Receiver: "", + Payload: testPayloadHex, + Sender: partySender, + Receiver: receiverHex, TokenTransfer: &oapiCommon.TokenTransfer{ Amount: tokenTransferAmountDecimal, Token: oapiCommon.InstrumentId{ diff --git a/integration-tests/ccip/ccip_send_with_token_lnr_test.go b/integration-tests/ccip/ccip_send_with_token_lnr_test.go index 0365394e2..70039476a 100644 --- a/integration-tests/ccip/ccip_send_with_token_lnr_test.go +++ b/integration-tests/ccip/ccip_send_with_token_lnr_test.go @@ -579,7 +579,7 @@ func TestLnRTokenPool_FullSendFlow(t *testing.T) { InstanceAddress: tokenPoolAddress.InstanceAddress(), }, PoolOwner: partySender, - TransferFactory: &config.TransferFactory{ + Factory: &config.Factory{ Type: config.FactoryTypeURL, TokenStandardURL: new(fmt.Sprintf("%s/v0/scan-proxy", ccipParticipant.Endpoints.ValidatorAPIURL)), TokenStandardAuthConfig: &commonconfig.AuthConfig{ @@ -753,8 +753,9 @@ func TestLnRTokenPool_FullSendFlow(t *testing.T) { Admin: oapiCommon.PartyId(nativeInstrumentId.Admin), Id: string(nativeInstrumentId.Id), }, - Payload: "", - Receiver: "", + Payload: testPayloadHex, + Sender: partySender, + Receiver: receiverHex, TokenTransfer: &oapiCommon.TokenTransfer{ Amount: tokenTransferAmountDecimal, Token: oapiCommon.InstrumentId{ diff --git a/openapi/gen/daRegistry/cfg.yaml b/openapi/gen/daRegistry/cfg.yaml new file mode 100644 index 000000000..0177e7929 --- /dev/null +++ b/openapi/gen/daRegistry/cfg.yaml @@ -0,0 +1,8 @@ +package: daRegistry +output: daRegistry.gen.go +generate: + models: true + client: true + gin-server: true +output-options: + response-type-suffix: Resp \ No newline at end of file diff --git a/openapi/gen/daRegistry/daRegistry.gen.go b/openapi/gen/daRegistry/daRegistry.gen.go new file mode 100644 index 000000000..ddce1f40e --- /dev/null +++ b/openapi/gen/daRegistry/daRegistry.gen.go @@ -0,0 +1,4507 @@ +// Package daRegistry provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.1 DO NOT EDIT. +package daRegistry + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strings" + "time" + + "github.com/gin-gonic/gin" + "github.com/oapi-codegen/runtime" +) + +// Defines values for TransferProofStatus. +const ( + Failure TransferProofStatus = "Failure" + Pending TransferProofStatus = "Pending" + Success TransferProofStatus = "Success" +) + +// ChoiceContext The context required to exercise a choice on a contract via an interface. +// Used to retrieve additional reference date that is passed in via disclosed contracts, +// which are in turn referred to via their contract ID in the `choiceContextData`. +type ChoiceContext struct { + // ChoiceContextData The additional data to use when exercising the choice. + ChoiceContextData map[string]interface{} `json:"choiceContextData"` + + // DisclosedContracts The contracts that are required to be disclosed to the participant node for exercising + // the choice. + DisclosedContracts []DisclosedContract `json:"disclosedContracts"` +} + +// ContractMeta defines model for ContractMeta. +type ContractMeta struct { + ContractId string `json:"contractId"` + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // DomainId Deprecated alias of synchronizerId kept for backward compatibility. + // Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set + DomainId *string `json:"domainId,omitempty"` + + // SynchronizerId Preferred synchronizer identifier for disclosed contracts and contract metadata. + SynchronizerId *string `json:"synchronizerId,omitempty"` + TemplateId string `json:"templateId"` +} + +// CredentialClaim defines model for CredentialClaim. +type CredentialClaim struct { + // Property The property of the claim + Property string `json:"property"` + + // Value The value of the claim + Value string `json:"value"` +} + +// DisclosedContract defines model for DisclosedContract. +type DisclosedContract struct { + ContractId string `json:"contractId"` + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // CreatedEventBlob The base64 encoded created event blob + CreatedEventBlob string `json:"createdEventBlob"` + + // DomainId Deprecated alias of synchronizerId kept for backward compatibility. + // Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set + DomainId *string `json:"domainId,omitempty"` + + // SynchronizerId Preferred synchronizer identifier for disclosed contracts and contract metadata. + SynchronizerId *string `json:"synchronizerId,omitempty"` + TemplateId string `json:"templateId"` +} + +// Error A problem occurred with processing the request. For instance: syntactically invalid JSON body, missing required fields, etc. +type Error struct { + // Error An error code, e.g. invalid_token + Error string `json:"error"` + + // ErrorDescription A description of the error + ErrorDescription string `json:"error_description"` +} + +// FactoryWithChoiceContext A factory contract together with the choice context required to exercise the choice +// provided by the factory. Typically used to implement the generic initiation of on-ledger workflows +// via a Daml interface. +// +// Clients SHOULD avoid reusing the same `FactoryWithChoiceContext` for exercising multiple choices, +// as the choice context MAY be specific to the choice being exercised. +type FactoryWithChoiceContext struct { + // ChoiceContext The context required to exercise a choice on a contract via an interface. + // Used to retrieve additional reference date that is passed in via disclosed contracts, + // which are in turn referred to via their contract ID in the `choiceContextData`. + ChoiceContext ChoiceContext `json:"choiceContext"` + + // FactoryId The contract ID of the contract of the factory which can be used to create instruction. + FactoryId string `json:"factoryId"` +} + +// GetAllInstrumentConfigurationsResponse defines model for GetAllInstrumentConfigurationsResponse. +type GetAllInstrumentConfigurationsResponse struct { + // InstrumentConfigurations All instrument configurations + InstrumentConfigurations []InstrumentConfiguration `json:"instrumentConfigurations"` +} + +// GetAllPackagesResponse defines model for GetAllPackagesResponse. +type GetAllPackagesResponse struct { + Packages []PackageDescriptor `json:"packages"` +} + +// GetBurnMintFactoryRequest The request to get the factory and choice context for burn and mint. +type GetBurnMintFactoryRequest struct { + // InputHoldingCids Contract ids of Holdings to be used for the burn. + InputHoldingCids []string `json:"inputHoldingCids"` + + // InstrumentId The identifier of the instrument. + InstrumentId InstrumentId `json:"instrumentId"` + + // Outputs The list of specification of a holding to be minted. + Outputs []MintOutput `json:"outputs"` +} + +// GetInstrumentConfigurationRequest defines model for GetInstrumentConfigurationRequest. +type GetInstrumentConfigurationRequest struct { + InstrumentIdentifier InstrumentIdentifier `json:"instrumentIdentifier"` + + // Registrar The registrar party id + Registrar string `json:"registrar"` +} + +// GetInstrumentConfigurationResponse defines model for GetInstrumentConfigurationResponse. +type GetInstrumentConfigurationResponse = InstrumentConfiguration + +// GetOperatorResponse defines model for GetOperatorResponse. +type GetOperatorResponse struct { + // PartyId The operator party id + PartyId string `json:"partyId"` +} + +// InstrumentConfiguration defines model for InstrumentConfiguration. +type InstrumentConfiguration struct { + Contract ContractMeta `json:"contract"` + Payload InstrumentConfigurationPayload `json:"payload"` +} + +// InstrumentConfigurationPayload defines model for InstrumentConfigurationPayload. +type InstrumentConfigurationPayload struct { + // AdditionalIdentifiers Additional instrument identifiers + AdditionalIdentifiers []InstrumentIdentifier `json:"additionalIdentifiers"` + DefaultIdentifier InstrumentIdentifier `json:"defaultIdentifier"` + + // HolderRequirements Credential requirements to transfer/lock/unlock a given asset + HolderRequirements []PartyCredentialRequirement `json:"holderRequirements"` + + // IssuerRequirements Credential requirements to mint/burn a given asset + IssuerRequirements []PartyCredentialRequirement `json:"issuerRequirements"` + + // Operator The operator party id + Operator string `json:"operator"` + + // Provider The provider party id + Provider string `json:"provider"` + + // Registrar The registrar party id + Registrar string `json:"registrar"` +} + +// InstrumentId The identifier of the instrument. +type InstrumentId struct { + // Admin The party administering the instrument. + Admin string `json:"admin"` + + // Id The unique identifier of the instrument. + Id string `json:"id"` +} + +// InstrumentIdentifier defines model for InstrumentIdentifier. +type InstrumentIdentifier struct { + // Id The identifier for the instrument + Id string `json:"id"` + + // Scheme The scheme or standard used for the identifier. + Scheme string `json:"scheme"` + + // Source The entity that originally created or issued the identifier. + Source string `json:"source"` +} + +// MintOutput The output to be minted. +type MintOutput struct { + // Amount The amount to be minted. + Amount string `json:"amount"` + + // Owner The party for whom the holding will be minted. + Owner string `json:"owner"` +} + +// OfferBurnRequest The request to get the factory and choice context for creating a burn offer. +type OfferBurnRequest struct { + // Holder The party whose holding will be burned. + Holder string `json:"holder"` + + // InstrumentId The identifier of the instrument. + InstrumentId InstrumentId `json:"instrumentId"` +} + +// OfferMintRequest The request to get the factory and choice context for creating a mint offer. +type OfferMintRequest struct { + // Holder The party for whom the holding will be minted. + Holder string `json:"holder"` + + // InstrumentId The identifier of the instrument. + InstrumentId InstrumentId `json:"instrumentId"` +} + +// PackageDescriptor Contains the package ids for a given package name +type PackageDescriptor struct { + // Id Package ID + Id string `json:"id"` + + // Name Name of the package + Name string `json:"name"` +} + +// PartyCredentialRequirement defines model for PartyCredentialRequirement. +type PartyCredentialRequirement struct { + // Issuer Required issuer of the credential + Issuer string `json:"issuer"` + + // RequiredClaims Required (property, value) pairs that the holder has to have claims for as a subject + RequiredClaims string `json:"requiredClaims"` +} + +// RequestBurnRequest The request to get the factory and choice context for creating a burn request. +type RequestBurnRequest struct { + // Holder The party whose holding will be burned. + Holder string `json:"holder"` + + // HoldingContractIds Contract ids of Holdings to be used for the burn. + HoldingContractIds []string `json:"holdingContractIds"` + + // InstrumentId The identifier of the instrument. + InstrumentId InstrumentId `json:"instrumentId"` +} + +// RequestMintRequest The request to get the factory and choice context for creating a mint request. +type RequestMintRequest struct { + // Holder The party for whom the holding will be minted. + Holder string `json:"holder"` + + // InstrumentId The identifier of the instrument. + InstrumentId InstrumentId `json:"instrumentId"` +} + +// TransferMeta Additional metadata associated with the transfer. +type TransferMeta struct { + // Values Arbitrary key-value metadata attached to the transfer. + Values map[string]string `json:"values"` +} + +// TransferObject The transfer payload containing transaction details known only to the sender and receiver. +type TransferObject struct { + // Amount The transfer amount as a decimal string. + Amount string `json:"amount"` + + // ExecuteBefore The deadline by which the transfer must be executed. + ExecuteBefore time.Time `json:"executeBefore"` + + // InputHoldingCids Contract IDs of the holdings used as inputs for the transfer. + InputHoldingCids []string `json:"inputHoldingCids"` + + // InstrumentId The identifier of the instrument. + InstrumentId InstrumentId `json:"instrumentId"` + + // Meta Additional metadata associated with the transfer. + Meta TransferMeta `json:"meta"` + + // Receiver The party ID of the transfer receiver. + Receiver string `json:"receiver"` + + // RequestedAt The timestamp when the transfer was requested. + RequestedAt time.Time `json:"requestedAt"` + + // Sender The party ID of the transfer sender. + Sender string `json:"sender"` +} + +// TransferProofStatus The status of the transfer proof verification: +// - `Success`: The proof is verified and the transfer was successfully concluded +// - `Failure`: The proof is verified, but the transfer did not successfully conclude. +// - `Pending`: The transaction is still in progress (e.g., a transfer offer has been sent but not yet accepted in a two-step flow). +type TransferProofStatus string + +// VerifyTransferProofRequest Request to verify the outcome of a transfer of Registry Utility assets on Canton. +type VerifyTransferProofRequest struct { + // Transfer The transfer payload containing transaction details known only to the sender and receiver. + Transfer TransferObject `json:"transfer"` + + // UpdateId For the two-step transfer workflow, specifies the most recent UpdateId. + // If the transfer has completed its second step (accept, reject, or withdraw), + // use the UpdateId associated with that action. Otherwise, use the UpdateId from the initial transfer offer. + UpdateId string `json:"updateId"` +} + +// VerifyTransferProofResponse The outcome of verifying a transfer proof. +type VerifyTransferProofResponse struct { + // Status The status of the transfer proof verification: + // - `Success`: The proof is verified and the transfer was successfully concluded + // - `Failure`: The proof is verified, but the transfer did not successfully conclude. + // - `Pending`: The transaction is still in progress (e.g., a transfer offer has been sent but not yet accepted in a two-step flow). + Status TransferProofStatus `json:"status"` +} + +// N400 A problem occurred with processing the request. For instance: syntactically invalid JSON body, missing required fields, etc. +type N400 = Error + +// N404 A problem occurred with processing the request. For instance: syntactically invalid JSON body, missing required fields, etc. +type N404 = Error + +// N500 A problem occurred with processing the request. For instance: syntactically invalid JSON body, missing required fields, etc. +type N500 = Error + +// GetInstrumentConfigurationJSONRequestBody defines body for GetInstrumentConfiguration for application/json ContentType. +type GetInstrumentConfigurationJSONRequestBody = GetInstrumentConfigurationRequest + +// GetBurnMintFactoryJSONRequestBody defines body for GetBurnMintFactory for application/json ContentType. +type GetBurnMintFactoryJSONRequestBody = GetBurnMintFactoryRequest + +// GetBurnOfferCreateContextJSONRequestBody defines body for GetBurnOfferCreateContext for application/json ContentType. +type GetBurnOfferCreateContextJSONRequestBody = OfferBurnRequest + +// GetBurnRequestCreateContextJSONRequestBody defines body for GetBurnRequestCreateContext for application/json ContentType. +type GetBurnRequestCreateContextJSONRequestBody = RequestBurnRequest + +// GetMintOfferCreateContextJSONRequestBody defines body for GetMintOfferCreateContext for application/json ContentType. +type GetMintOfferCreateContextJSONRequestBody = OfferMintRequest + +// GetMintRequestCreateContextJSONRequestBody defines body for GetMintRequestCreateContext for application/json ContentType. +type GetMintRequestCreateContextJSONRequestBody = RequestMintRequest + +// VerifyTransferProofJSONRequestBody defines body for VerifyTransferProof for application/json ContentType. +type VerifyTransferProofJSONRequestBody = VerifyTransferProofRequest + +// RequestEditorFn is the function signature for the RequestEditor callback function +type RequestEditorFn func(ctx context.Context, req *http.Request) error + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HttpRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// Client which conforms to the OpenAPI3 specification for this service. +type Client struct { + // The endpoint of the server conforming to this interface, with scheme, + // https://api.deepmap.com for example. This can contain a path relative + // to the server, such as https://api.deepmap.com/dev-test, and all the + // paths in the swagger spec will be appended to the server. + Server string + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HttpRequestDoer + + // A list of callbacks for modifying requests which are generated before sending over + // the network. + RequestEditors []RequestEditorFn +} + +// ClientOption allows setting custom parameters during construction +type ClientOption func(*Client) error + +// Creates a new Client, with reasonable defaults +func NewClient(server string, opts ...ClientOption) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + } + // mutate client and add all optional params + for _, o := range opts { + if err := o(&client); err != nil { + return nil, err + } + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +// WithHTTPClient allows overriding the default Doer, which is +// automatically created using http.Client. This is useful for tests. +func WithHTTPClient(doer HttpRequestDoer) ClientOption { + return func(c *Client) error { + c.Client = doer + return nil + } +} + +// WithRequestEditorFn allows setting up a callback function, which will be +// called right before sending the request. This can be used to mutate the request. +func WithRequestEditorFn(fn RequestEditorFn) ClientOption { + return func(c *Client) error { + c.RequestEditors = append(c.RequestEditors, fn) + return nil + } +} + +// The interface specification for the client above. +type ClientInterface interface { + // Root request + Root(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetInstrumentConfigurationWithBody request with any body + GetInstrumentConfigurationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + GetInstrumentConfiguration(ctx context.Context, body GetInstrumentConfigurationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAllInstrumentConfigurations request + GetAllInstrumentConfigurations(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetOpenApiSpec request + GetOpenApiSpec(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetOperator request + GetOperator(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAllPackages request + GetAllPackages(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetBurnMintFactoryWithBody request with any body + GetBurnMintFactoryWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + GetBurnMintFactory(ctx context.Context, body GetBurnMintFactoryJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetBurnOfferCreateContextWithBody request with any body + GetBurnOfferCreateContextWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + GetBurnOfferCreateContext(ctx context.Context, body GetBurnOfferCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetBurnOfferAcceptContext request + GetBurnOfferAcceptContext(ctx context.Context, burnOfferId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetBurnOfferCancelContext request + GetBurnOfferCancelContext(ctx context.Context, burnOfferId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetBurnOfferRejectContext request + GetBurnOfferRejectContext(ctx context.Context, burnOfferId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetBurnRequestCreateContextWithBody request with any body + GetBurnRequestCreateContextWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + GetBurnRequestCreateContext(ctx context.Context, body GetBurnRequestCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetBurnRequestAcceptContext request + GetBurnRequestAcceptContext(ctx context.Context, burnRequestId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetBurnRequestCancelContext request + GetBurnRequestCancelContext(ctx context.Context, burnRequestId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetBurnRequestRejectContext request + GetBurnRequestRejectContext(ctx context.Context, burnRequestId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetMintOfferCreateContextWithBody request with any body + GetMintOfferCreateContextWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + GetMintOfferCreateContext(ctx context.Context, body GetMintOfferCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetMintOfferAcceptContext request + GetMintOfferAcceptContext(ctx context.Context, mintOfferId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetMintOfferCancelContext request + GetMintOfferCancelContext(ctx context.Context, mintOfferId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetMintOfferRejectContext request + GetMintOfferRejectContext(ctx context.Context, mintOfferId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetMintRequestCreateContextWithBody request with any body + GetMintRequestCreateContextWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + GetMintRequestCreateContext(ctx context.Context, body GetMintRequestCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetMintRequestAcceptContext request + GetMintRequestAcceptContext(ctx context.Context, mintRequestId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetMintRequestCancelContext request + GetMintRequestCancelContext(ctx context.Context, mintRequestId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetMintRequestRejectContext request + GetMintRequestRejectContext(ctx context.Context, mintRequestId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // VerifyTransferProofWithBody request with any body + VerifyTransferProofWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + VerifyTransferProof(ctx context.Context, body VerifyTransferProofJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // IsLive request + IsLive(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // IsReady request + IsReady(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +func (c *Client) Root(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRootRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetInstrumentConfigurationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetInstrumentConfigurationRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetInstrumentConfiguration(ctx context.Context, body GetInstrumentConfigurationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetInstrumentConfigurationRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetAllInstrumentConfigurations(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAllInstrumentConfigurationsRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetOpenApiSpec(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetOpenApiSpecRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetOperator(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetOperatorRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetAllPackages(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAllPackagesRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetBurnMintFactoryWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBurnMintFactoryRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetBurnMintFactory(ctx context.Context, body GetBurnMintFactoryJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBurnMintFactoryRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetBurnOfferCreateContextWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBurnOfferCreateContextRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetBurnOfferCreateContext(ctx context.Context, body GetBurnOfferCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBurnOfferCreateContextRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetBurnOfferAcceptContext(ctx context.Context, burnOfferId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBurnOfferAcceptContextRequest(c.Server, burnOfferId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetBurnOfferCancelContext(ctx context.Context, burnOfferId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBurnOfferCancelContextRequest(c.Server, burnOfferId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetBurnOfferRejectContext(ctx context.Context, burnOfferId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBurnOfferRejectContextRequest(c.Server, burnOfferId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetBurnRequestCreateContextWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBurnRequestCreateContextRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetBurnRequestCreateContext(ctx context.Context, body GetBurnRequestCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBurnRequestCreateContextRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetBurnRequestAcceptContext(ctx context.Context, burnRequestId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBurnRequestAcceptContextRequest(c.Server, burnRequestId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetBurnRequestCancelContext(ctx context.Context, burnRequestId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBurnRequestCancelContextRequest(c.Server, burnRequestId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetBurnRequestRejectContext(ctx context.Context, burnRequestId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBurnRequestRejectContextRequest(c.Server, burnRequestId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetMintOfferCreateContextWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetMintOfferCreateContextRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetMintOfferCreateContext(ctx context.Context, body GetMintOfferCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetMintOfferCreateContextRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetMintOfferAcceptContext(ctx context.Context, mintOfferId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetMintOfferAcceptContextRequest(c.Server, mintOfferId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetMintOfferCancelContext(ctx context.Context, mintOfferId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetMintOfferCancelContextRequest(c.Server, mintOfferId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetMintOfferRejectContext(ctx context.Context, mintOfferId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetMintOfferRejectContextRequest(c.Server, mintOfferId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetMintRequestCreateContextWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetMintRequestCreateContextRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetMintRequestCreateContext(ctx context.Context, body GetMintRequestCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetMintRequestCreateContextRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetMintRequestAcceptContext(ctx context.Context, mintRequestId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetMintRequestAcceptContextRequest(c.Server, mintRequestId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetMintRequestCancelContext(ctx context.Context, mintRequestId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetMintRequestCancelContextRequest(c.Server, mintRequestId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetMintRequestRejectContext(ctx context.Context, mintRequestId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetMintRequestRejectContextRequest(c.Server, mintRequestId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) VerifyTransferProofWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewVerifyTransferProofRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) VerifyTransferProof(ctx context.Context, body VerifyTransferProofJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewVerifyTransferProofRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) IsLive(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewIsLiveRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) IsReady(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewIsReadyRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewRootRequest generates requests for Root +func NewRootRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetInstrumentConfigurationRequest calls the generic GetInstrumentConfiguration builder with application/json body +func NewGetInstrumentConfigurationRequest(server string, body GetInstrumentConfigurationJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewGetInstrumentConfigurationRequestWithBody(server, "application/json", bodyReader) +} + +// NewGetInstrumentConfigurationRequestWithBody generates requests for GetInstrumentConfiguration with any type of body +func NewGetInstrumentConfigurationRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/contract/instrument-configuration") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetAllInstrumentConfigurationsRequest generates requests for GetAllInstrumentConfigurations +func NewGetAllInstrumentConfigurationsRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/contract/instrument-configuration/all") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetOpenApiSpecRequest generates requests for GetOpenApiSpec +func NewGetOpenApiSpecRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/openapi") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetOperatorRequest generates requests for GetOperator +func NewGetOperatorRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/operator") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetAllPackagesRequest generates requests for GetAllPackages +func NewGetAllPackagesRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/package/all") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetBurnMintFactoryRequest calls the generic GetBurnMintFactory builder with application/json body +func NewGetBurnMintFactoryRequest(server string, body GetBurnMintFactoryJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewGetBurnMintFactoryRequestWithBody(server, "application/json", bodyReader) +} + +// NewGetBurnMintFactoryRequestWithBody generates requests for GetBurnMintFactory with any type of body +func NewGetBurnMintFactoryRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/burn-mint-instruction/v0/burn-mint-factory") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetBurnOfferCreateContextRequest calls the generic GetBurnOfferCreateContext builder with application/json body +func NewGetBurnOfferCreateContextRequest(server string, body GetBurnOfferCreateContextJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewGetBurnOfferCreateContextRequestWithBody(server, "application/json", bodyReader) +} + +// NewGetBurnOfferCreateContextRequestWithBody generates requests for GetBurnOfferCreateContext with any type of body +func NewGetBurnOfferCreateContextRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/burn/v0/offer") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetBurnOfferAcceptContextRequest generates requests for GetBurnOfferAcceptContext +func NewGetBurnOfferAcceptContextRequest(server string, burnOfferId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "burnOfferId", runtime.ParamLocationPath, burnOfferId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/burn/v0/offer/%s/choice-contexts/accept", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetBurnOfferCancelContextRequest generates requests for GetBurnOfferCancelContext +func NewGetBurnOfferCancelContextRequest(server string, burnOfferId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "burnOfferId", runtime.ParamLocationPath, burnOfferId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/burn/v0/offer/%s/choice-contexts/cancel", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetBurnOfferRejectContextRequest generates requests for GetBurnOfferRejectContext +func NewGetBurnOfferRejectContextRequest(server string, burnOfferId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "burnOfferId", runtime.ParamLocationPath, burnOfferId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/burn/v0/offer/%s/choice-contexts/reject", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetBurnRequestCreateContextRequest calls the generic GetBurnRequestCreateContext builder with application/json body +func NewGetBurnRequestCreateContextRequest(server string, body GetBurnRequestCreateContextJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewGetBurnRequestCreateContextRequestWithBody(server, "application/json", bodyReader) +} + +// NewGetBurnRequestCreateContextRequestWithBody generates requests for GetBurnRequestCreateContext with any type of body +func NewGetBurnRequestCreateContextRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/burn/v0/request") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetBurnRequestAcceptContextRequest generates requests for GetBurnRequestAcceptContext +func NewGetBurnRequestAcceptContextRequest(server string, burnRequestId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "burnRequestId", runtime.ParamLocationPath, burnRequestId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/burn/v0/request/%s/choice-contexts/accept", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetBurnRequestCancelContextRequest generates requests for GetBurnRequestCancelContext +func NewGetBurnRequestCancelContextRequest(server string, burnRequestId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "burnRequestId", runtime.ParamLocationPath, burnRequestId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/burn/v0/request/%s/choice-contexts/cancel", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetBurnRequestRejectContextRequest generates requests for GetBurnRequestRejectContext +func NewGetBurnRequestRejectContextRequest(server string, burnRequestId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "burnRequestId", runtime.ParamLocationPath, burnRequestId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/burn/v0/request/%s/choice-contexts/reject", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetMintOfferCreateContextRequest calls the generic GetMintOfferCreateContext builder with application/json body +func NewGetMintOfferCreateContextRequest(server string, body GetMintOfferCreateContextJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewGetMintOfferCreateContextRequestWithBody(server, "application/json", bodyReader) +} + +// NewGetMintOfferCreateContextRequestWithBody generates requests for GetMintOfferCreateContext with any type of body +func NewGetMintOfferCreateContextRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/mint/v0/offer") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetMintOfferAcceptContextRequest generates requests for GetMintOfferAcceptContext +func NewGetMintOfferAcceptContextRequest(server string, mintOfferId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "mintOfferId", runtime.ParamLocationPath, mintOfferId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/mint/v0/offer/%s/choice-contexts/accept", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetMintOfferCancelContextRequest generates requests for GetMintOfferCancelContext +func NewGetMintOfferCancelContextRequest(server string, mintOfferId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "mintOfferId", runtime.ParamLocationPath, mintOfferId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/mint/v0/offer/%s/choice-contexts/cancel", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetMintOfferRejectContextRequest generates requests for GetMintOfferRejectContext +func NewGetMintOfferRejectContextRequest(server string, mintOfferId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "mintOfferId", runtime.ParamLocationPath, mintOfferId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/mint/v0/offer/%s/choice-contexts/reject", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetMintRequestCreateContextRequest calls the generic GetMintRequestCreateContext builder with application/json body +func NewGetMintRequestCreateContextRequest(server string, body GetMintRequestCreateContextJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewGetMintRequestCreateContextRequestWithBody(server, "application/json", bodyReader) +} + +// NewGetMintRequestCreateContextRequestWithBody generates requests for GetMintRequestCreateContext with any type of body +func NewGetMintRequestCreateContextRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/mint/v0/request") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetMintRequestAcceptContextRequest generates requests for GetMintRequestAcceptContext +func NewGetMintRequestAcceptContextRequest(server string, mintRequestId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "mintRequestId", runtime.ParamLocationPath, mintRequestId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/mint/v0/request/%s/choice-contexts/accept", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetMintRequestCancelContextRequest generates requests for GetMintRequestCancelContext +func NewGetMintRequestCancelContextRequest(server string, mintRequestId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "mintRequestId", runtime.ParamLocationPath, mintRequestId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/mint/v0/request/%s/choice-contexts/cancel", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetMintRequestRejectContextRequest generates requests for GetMintRequestRejectContext +func NewGetMintRequestRejectContextRequest(server string, mintRequestId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "mintRequestId", runtime.ParamLocationPath, mintRequestId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/mint/v0/request/%s/choice-contexts/reject", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewVerifyTransferProofRequest calls the generic VerifyTransferProof builder with application/json body +func NewVerifyTransferProofRequest(server string, body VerifyTransferProofJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewVerifyTransferProofRequestWithBody(server, "application/json", bodyReader) +} + +// NewVerifyTransferProofRequestWithBody generates requests for VerifyTransferProof with any type of body +func NewVerifyTransferProofRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/utilities/v0/registry/transfer/v0/proof") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewIsLiveRequest generates requests for IsLive +func NewIsLiveRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/livez") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewIsReadyRequest generates requests for IsReady +func NewIsReadyRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/readyz") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // RootWithResponse request + RootWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*RootResp, error) + + // GetInstrumentConfigurationWithBodyWithResponse request with any body + GetInstrumentConfigurationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetInstrumentConfigurationResp, error) + + GetInstrumentConfigurationWithResponse(ctx context.Context, body GetInstrumentConfigurationJSONRequestBody, reqEditors ...RequestEditorFn) (*GetInstrumentConfigurationResp, error) + + // GetAllInstrumentConfigurationsWithResponse request + GetAllInstrumentConfigurationsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAllInstrumentConfigurationsResp, error) + + // GetOpenApiSpecWithResponse request + GetOpenApiSpecWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetOpenApiSpecResp, error) + + // GetOperatorWithResponse request + GetOperatorWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetOperatorResp, error) + + // GetAllPackagesWithResponse request + GetAllPackagesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAllPackagesResp, error) + + // GetBurnMintFactoryWithBodyWithResponse request with any body + GetBurnMintFactoryWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetBurnMintFactoryResp, error) + + GetBurnMintFactoryWithResponse(ctx context.Context, body GetBurnMintFactoryJSONRequestBody, reqEditors ...RequestEditorFn) (*GetBurnMintFactoryResp, error) + + // GetBurnOfferCreateContextWithBodyWithResponse request with any body + GetBurnOfferCreateContextWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetBurnOfferCreateContextResp, error) + + GetBurnOfferCreateContextWithResponse(ctx context.Context, body GetBurnOfferCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*GetBurnOfferCreateContextResp, error) + + // GetBurnOfferAcceptContextWithResponse request + GetBurnOfferAcceptContextWithResponse(ctx context.Context, burnOfferId string, reqEditors ...RequestEditorFn) (*GetBurnOfferAcceptContextResp, error) + + // GetBurnOfferCancelContextWithResponse request + GetBurnOfferCancelContextWithResponse(ctx context.Context, burnOfferId string, reqEditors ...RequestEditorFn) (*GetBurnOfferCancelContextResp, error) + + // GetBurnOfferRejectContextWithResponse request + GetBurnOfferRejectContextWithResponse(ctx context.Context, burnOfferId string, reqEditors ...RequestEditorFn) (*GetBurnOfferRejectContextResp, error) + + // GetBurnRequestCreateContextWithBodyWithResponse request with any body + GetBurnRequestCreateContextWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetBurnRequestCreateContextResp, error) + + GetBurnRequestCreateContextWithResponse(ctx context.Context, body GetBurnRequestCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*GetBurnRequestCreateContextResp, error) + + // GetBurnRequestAcceptContextWithResponse request + GetBurnRequestAcceptContextWithResponse(ctx context.Context, burnRequestId string, reqEditors ...RequestEditorFn) (*GetBurnRequestAcceptContextResp, error) + + // GetBurnRequestCancelContextWithResponse request + GetBurnRequestCancelContextWithResponse(ctx context.Context, burnRequestId string, reqEditors ...RequestEditorFn) (*GetBurnRequestCancelContextResp, error) + + // GetBurnRequestRejectContextWithResponse request + GetBurnRequestRejectContextWithResponse(ctx context.Context, burnRequestId string, reqEditors ...RequestEditorFn) (*GetBurnRequestRejectContextResp, error) + + // GetMintOfferCreateContextWithBodyWithResponse request with any body + GetMintOfferCreateContextWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetMintOfferCreateContextResp, error) + + GetMintOfferCreateContextWithResponse(ctx context.Context, body GetMintOfferCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*GetMintOfferCreateContextResp, error) + + // GetMintOfferAcceptContextWithResponse request + GetMintOfferAcceptContextWithResponse(ctx context.Context, mintOfferId string, reqEditors ...RequestEditorFn) (*GetMintOfferAcceptContextResp, error) + + // GetMintOfferCancelContextWithResponse request + GetMintOfferCancelContextWithResponse(ctx context.Context, mintOfferId string, reqEditors ...RequestEditorFn) (*GetMintOfferCancelContextResp, error) + + // GetMintOfferRejectContextWithResponse request + GetMintOfferRejectContextWithResponse(ctx context.Context, mintOfferId string, reqEditors ...RequestEditorFn) (*GetMintOfferRejectContextResp, error) + + // GetMintRequestCreateContextWithBodyWithResponse request with any body + GetMintRequestCreateContextWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetMintRequestCreateContextResp, error) + + GetMintRequestCreateContextWithResponse(ctx context.Context, body GetMintRequestCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*GetMintRequestCreateContextResp, error) + + // GetMintRequestAcceptContextWithResponse request + GetMintRequestAcceptContextWithResponse(ctx context.Context, mintRequestId string, reqEditors ...RequestEditorFn) (*GetMintRequestAcceptContextResp, error) + + // GetMintRequestCancelContextWithResponse request + GetMintRequestCancelContextWithResponse(ctx context.Context, mintRequestId string, reqEditors ...RequestEditorFn) (*GetMintRequestCancelContextResp, error) + + // GetMintRequestRejectContextWithResponse request + GetMintRequestRejectContextWithResponse(ctx context.Context, mintRequestId string, reqEditors ...RequestEditorFn) (*GetMintRequestRejectContextResp, error) + + // VerifyTransferProofWithBodyWithResponse request with any body + VerifyTransferProofWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*VerifyTransferProofResp, error) + + VerifyTransferProofWithResponse(ctx context.Context, body VerifyTransferProofJSONRequestBody, reqEditors ...RequestEditorFn) (*VerifyTransferProofResp, error) + + // IsLiveWithResponse request + IsLiveWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*IsLiveResp, error) + + // IsReadyWithResponse request + IsReadyWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*IsReadyResp, error) +} + +type RootResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r RootResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RootResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetInstrumentConfigurationResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *GetInstrumentConfigurationResponse + JSON404 *Error + JSON500 *Error +} + +// Status returns HTTPResponse.Status +func (r GetInstrumentConfigurationResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetInstrumentConfigurationResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetAllInstrumentConfigurationsResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *GetAllInstrumentConfigurationsResponse + JSON500 *Error +} + +// Status returns HTTPResponse.Status +func (r GetAllInstrumentConfigurationsResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetAllInstrumentConfigurationsResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetOpenApiSpecResp struct { + Body []byte + HTTPResponse *http.Response + JSON500 *Error +} + +// Status returns HTTPResponse.Status +func (r GetOpenApiSpecResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetOpenApiSpecResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetOperatorResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *GetOperatorResponse + JSON500 *Error +} + +// Status returns HTTPResponse.Status +func (r GetOperatorResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetOperatorResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetAllPackagesResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *GetAllPackagesResponse + JSON500 *Error +} + +// Status returns HTTPResponse.Status +func (r GetAllPackagesResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetAllPackagesResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetBurnMintFactoryResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FactoryWithChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetBurnMintFactoryResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetBurnMintFactoryResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetBurnOfferCreateContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FactoryWithChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetBurnOfferCreateContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetBurnOfferCreateContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetBurnOfferAcceptContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetBurnOfferAcceptContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetBurnOfferAcceptContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetBurnOfferCancelContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetBurnOfferCancelContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetBurnOfferCancelContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetBurnOfferRejectContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetBurnOfferRejectContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetBurnOfferRejectContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetBurnRequestCreateContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FactoryWithChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetBurnRequestCreateContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetBurnRequestCreateContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetBurnRequestAcceptContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetBurnRequestAcceptContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetBurnRequestAcceptContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetBurnRequestCancelContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetBurnRequestCancelContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetBurnRequestCancelContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetBurnRequestRejectContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetBurnRequestRejectContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetBurnRequestRejectContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetMintOfferCreateContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FactoryWithChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetMintOfferCreateContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetMintOfferCreateContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetMintOfferAcceptContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetMintOfferAcceptContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetMintOfferAcceptContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetMintOfferCancelContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetMintOfferCancelContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetMintOfferCancelContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetMintOfferRejectContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetMintOfferRejectContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetMintOfferRejectContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetMintRequestCreateContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FactoryWithChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetMintRequestCreateContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetMintRequestCreateContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetMintRequestAcceptContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetMintRequestAcceptContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetMintRequestAcceptContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetMintRequestCancelContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetMintRequestCancelContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetMintRequestCancelContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetMintRequestRejectContextResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ChoiceContext + JSON400 *N400 + JSON404 *N404 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r GetMintRequestRejectContextResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetMintRequestRejectContextResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type VerifyTransferProofResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *VerifyTransferProofResponse + JSON400 *N400 + JSON500 *N500 +} + +// Status returns HTTPResponse.Status +func (r VerifyTransferProofResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r VerifyTransferProofResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type IsLiveResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r IsLiveResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r IsLiveResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type IsReadyResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r IsReadyResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r IsReadyResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// RootWithResponse request returning *RootResp +func (c *ClientWithResponses) RootWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*RootResp, error) { + rsp, err := c.Root(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseRootResp(rsp) +} + +// GetInstrumentConfigurationWithBodyWithResponse request with arbitrary body returning *GetInstrumentConfigurationResp +func (c *ClientWithResponses) GetInstrumentConfigurationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetInstrumentConfigurationResp, error) { + rsp, err := c.GetInstrumentConfigurationWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetInstrumentConfigurationResp(rsp) +} + +func (c *ClientWithResponses) GetInstrumentConfigurationWithResponse(ctx context.Context, body GetInstrumentConfigurationJSONRequestBody, reqEditors ...RequestEditorFn) (*GetInstrumentConfigurationResp, error) { + rsp, err := c.GetInstrumentConfiguration(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetInstrumentConfigurationResp(rsp) +} + +// GetAllInstrumentConfigurationsWithResponse request returning *GetAllInstrumentConfigurationsResp +func (c *ClientWithResponses) GetAllInstrumentConfigurationsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAllInstrumentConfigurationsResp, error) { + rsp, err := c.GetAllInstrumentConfigurations(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAllInstrumentConfigurationsResp(rsp) +} + +// GetOpenApiSpecWithResponse request returning *GetOpenApiSpecResp +func (c *ClientWithResponses) GetOpenApiSpecWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetOpenApiSpecResp, error) { + rsp, err := c.GetOpenApiSpec(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetOpenApiSpecResp(rsp) +} + +// GetOperatorWithResponse request returning *GetOperatorResp +func (c *ClientWithResponses) GetOperatorWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetOperatorResp, error) { + rsp, err := c.GetOperator(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetOperatorResp(rsp) +} + +// GetAllPackagesWithResponse request returning *GetAllPackagesResp +func (c *ClientWithResponses) GetAllPackagesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAllPackagesResp, error) { + rsp, err := c.GetAllPackages(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAllPackagesResp(rsp) +} + +// GetBurnMintFactoryWithBodyWithResponse request with arbitrary body returning *GetBurnMintFactoryResp +func (c *ClientWithResponses) GetBurnMintFactoryWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetBurnMintFactoryResp, error) { + rsp, err := c.GetBurnMintFactoryWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBurnMintFactoryResp(rsp) +} + +func (c *ClientWithResponses) GetBurnMintFactoryWithResponse(ctx context.Context, body GetBurnMintFactoryJSONRequestBody, reqEditors ...RequestEditorFn) (*GetBurnMintFactoryResp, error) { + rsp, err := c.GetBurnMintFactory(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBurnMintFactoryResp(rsp) +} + +// GetBurnOfferCreateContextWithBodyWithResponse request with arbitrary body returning *GetBurnOfferCreateContextResp +func (c *ClientWithResponses) GetBurnOfferCreateContextWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetBurnOfferCreateContextResp, error) { + rsp, err := c.GetBurnOfferCreateContextWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBurnOfferCreateContextResp(rsp) +} + +func (c *ClientWithResponses) GetBurnOfferCreateContextWithResponse(ctx context.Context, body GetBurnOfferCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*GetBurnOfferCreateContextResp, error) { + rsp, err := c.GetBurnOfferCreateContext(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBurnOfferCreateContextResp(rsp) +} + +// GetBurnOfferAcceptContextWithResponse request returning *GetBurnOfferAcceptContextResp +func (c *ClientWithResponses) GetBurnOfferAcceptContextWithResponse(ctx context.Context, burnOfferId string, reqEditors ...RequestEditorFn) (*GetBurnOfferAcceptContextResp, error) { + rsp, err := c.GetBurnOfferAcceptContext(ctx, burnOfferId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBurnOfferAcceptContextResp(rsp) +} + +// GetBurnOfferCancelContextWithResponse request returning *GetBurnOfferCancelContextResp +func (c *ClientWithResponses) GetBurnOfferCancelContextWithResponse(ctx context.Context, burnOfferId string, reqEditors ...RequestEditorFn) (*GetBurnOfferCancelContextResp, error) { + rsp, err := c.GetBurnOfferCancelContext(ctx, burnOfferId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBurnOfferCancelContextResp(rsp) +} + +// GetBurnOfferRejectContextWithResponse request returning *GetBurnOfferRejectContextResp +func (c *ClientWithResponses) GetBurnOfferRejectContextWithResponse(ctx context.Context, burnOfferId string, reqEditors ...RequestEditorFn) (*GetBurnOfferRejectContextResp, error) { + rsp, err := c.GetBurnOfferRejectContext(ctx, burnOfferId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBurnOfferRejectContextResp(rsp) +} + +// GetBurnRequestCreateContextWithBodyWithResponse request with arbitrary body returning *GetBurnRequestCreateContextResp +func (c *ClientWithResponses) GetBurnRequestCreateContextWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetBurnRequestCreateContextResp, error) { + rsp, err := c.GetBurnRequestCreateContextWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBurnRequestCreateContextResp(rsp) +} + +func (c *ClientWithResponses) GetBurnRequestCreateContextWithResponse(ctx context.Context, body GetBurnRequestCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*GetBurnRequestCreateContextResp, error) { + rsp, err := c.GetBurnRequestCreateContext(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBurnRequestCreateContextResp(rsp) +} + +// GetBurnRequestAcceptContextWithResponse request returning *GetBurnRequestAcceptContextResp +func (c *ClientWithResponses) GetBurnRequestAcceptContextWithResponse(ctx context.Context, burnRequestId string, reqEditors ...RequestEditorFn) (*GetBurnRequestAcceptContextResp, error) { + rsp, err := c.GetBurnRequestAcceptContext(ctx, burnRequestId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBurnRequestAcceptContextResp(rsp) +} + +// GetBurnRequestCancelContextWithResponse request returning *GetBurnRequestCancelContextResp +func (c *ClientWithResponses) GetBurnRequestCancelContextWithResponse(ctx context.Context, burnRequestId string, reqEditors ...RequestEditorFn) (*GetBurnRequestCancelContextResp, error) { + rsp, err := c.GetBurnRequestCancelContext(ctx, burnRequestId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBurnRequestCancelContextResp(rsp) +} + +// GetBurnRequestRejectContextWithResponse request returning *GetBurnRequestRejectContextResp +func (c *ClientWithResponses) GetBurnRequestRejectContextWithResponse(ctx context.Context, burnRequestId string, reqEditors ...RequestEditorFn) (*GetBurnRequestRejectContextResp, error) { + rsp, err := c.GetBurnRequestRejectContext(ctx, burnRequestId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBurnRequestRejectContextResp(rsp) +} + +// GetMintOfferCreateContextWithBodyWithResponse request with arbitrary body returning *GetMintOfferCreateContextResp +func (c *ClientWithResponses) GetMintOfferCreateContextWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetMintOfferCreateContextResp, error) { + rsp, err := c.GetMintOfferCreateContextWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetMintOfferCreateContextResp(rsp) +} + +func (c *ClientWithResponses) GetMintOfferCreateContextWithResponse(ctx context.Context, body GetMintOfferCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*GetMintOfferCreateContextResp, error) { + rsp, err := c.GetMintOfferCreateContext(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetMintOfferCreateContextResp(rsp) +} + +// GetMintOfferAcceptContextWithResponse request returning *GetMintOfferAcceptContextResp +func (c *ClientWithResponses) GetMintOfferAcceptContextWithResponse(ctx context.Context, mintOfferId string, reqEditors ...RequestEditorFn) (*GetMintOfferAcceptContextResp, error) { + rsp, err := c.GetMintOfferAcceptContext(ctx, mintOfferId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetMintOfferAcceptContextResp(rsp) +} + +// GetMintOfferCancelContextWithResponse request returning *GetMintOfferCancelContextResp +func (c *ClientWithResponses) GetMintOfferCancelContextWithResponse(ctx context.Context, mintOfferId string, reqEditors ...RequestEditorFn) (*GetMintOfferCancelContextResp, error) { + rsp, err := c.GetMintOfferCancelContext(ctx, mintOfferId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetMintOfferCancelContextResp(rsp) +} + +// GetMintOfferRejectContextWithResponse request returning *GetMintOfferRejectContextResp +func (c *ClientWithResponses) GetMintOfferRejectContextWithResponse(ctx context.Context, mintOfferId string, reqEditors ...RequestEditorFn) (*GetMintOfferRejectContextResp, error) { + rsp, err := c.GetMintOfferRejectContext(ctx, mintOfferId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetMintOfferRejectContextResp(rsp) +} + +// GetMintRequestCreateContextWithBodyWithResponse request with arbitrary body returning *GetMintRequestCreateContextResp +func (c *ClientWithResponses) GetMintRequestCreateContextWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetMintRequestCreateContextResp, error) { + rsp, err := c.GetMintRequestCreateContextWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetMintRequestCreateContextResp(rsp) +} + +func (c *ClientWithResponses) GetMintRequestCreateContextWithResponse(ctx context.Context, body GetMintRequestCreateContextJSONRequestBody, reqEditors ...RequestEditorFn) (*GetMintRequestCreateContextResp, error) { + rsp, err := c.GetMintRequestCreateContext(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetMintRequestCreateContextResp(rsp) +} + +// GetMintRequestAcceptContextWithResponse request returning *GetMintRequestAcceptContextResp +func (c *ClientWithResponses) GetMintRequestAcceptContextWithResponse(ctx context.Context, mintRequestId string, reqEditors ...RequestEditorFn) (*GetMintRequestAcceptContextResp, error) { + rsp, err := c.GetMintRequestAcceptContext(ctx, mintRequestId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetMintRequestAcceptContextResp(rsp) +} + +// GetMintRequestCancelContextWithResponse request returning *GetMintRequestCancelContextResp +func (c *ClientWithResponses) GetMintRequestCancelContextWithResponse(ctx context.Context, mintRequestId string, reqEditors ...RequestEditorFn) (*GetMintRequestCancelContextResp, error) { + rsp, err := c.GetMintRequestCancelContext(ctx, mintRequestId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetMintRequestCancelContextResp(rsp) +} + +// GetMintRequestRejectContextWithResponse request returning *GetMintRequestRejectContextResp +func (c *ClientWithResponses) GetMintRequestRejectContextWithResponse(ctx context.Context, mintRequestId string, reqEditors ...RequestEditorFn) (*GetMintRequestRejectContextResp, error) { + rsp, err := c.GetMintRequestRejectContext(ctx, mintRequestId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetMintRequestRejectContextResp(rsp) +} + +// VerifyTransferProofWithBodyWithResponse request with arbitrary body returning *VerifyTransferProofResp +func (c *ClientWithResponses) VerifyTransferProofWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*VerifyTransferProofResp, error) { + rsp, err := c.VerifyTransferProofWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseVerifyTransferProofResp(rsp) +} + +func (c *ClientWithResponses) VerifyTransferProofWithResponse(ctx context.Context, body VerifyTransferProofJSONRequestBody, reqEditors ...RequestEditorFn) (*VerifyTransferProofResp, error) { + rsp, err := c.VerifyTransferProof(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseVerifyTransferProofResp(rsp) +} + +// IsLiveWithResponse request returning *IsLiveResp +func (c *ClientWithResponses) IsLiveWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*IsLiveResp, error) { + rsp, err := c.IsLive(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseIsLiveResp(rsp) +} + +// IsReadyWithResponse request returning *IsReadyResp +func (c *ClientWithResponses) IsReadyWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*IsReadyResp, error) { + rsp, err := c.IsReady(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseIsReadyResp(rsp) +} + +// ParseRootResp parses an HTTP response from a RootWithResponse call +func ParseRootResp(rsp *http.Response) (*RootResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RootResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseGetInstrumentConfigurationResp parses an HTTP response from a GetInstrumentConfigurationWithResponse call +func ParseGetInstrumentConfigurationResp(rsp *http.Response) (*GetInstrumentConfigurationResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetInstrumentConfigurationResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest GetInstrumentConfigurationResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetAllInstrumentConfigurationsResp parses an HTTP response from a GetAllInstrumentConfigurationsWithResponse call +func ParseGetAllInstrumentConfigurationsResp(rsp *http.Response) (*GetAllInstrumentConfigurationsResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAllInstrumentConfigurationsResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest GetAllInstrumentConfigurationsResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetOpenApiSpecResp parses an HTTP response from a GetOpenApiSpecWithResponse call +func ParseGetOpenApiSpecResp(rsp *http.Response) (*GetOpenApiSpecResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetOpenApiSpecResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetOperatorResp parses an HTTP response from a GetOperatorWithResponse call +func ParseGetOperatorResp(rsp *http.Response) (*GetOperatorResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetOperatorResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest GetOperatorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetAllPackagesResp parses an HTTP response from a GetAllPackagesWithResponse call +func ParseGetAllPackagesResp(rsp *http.Response) (*GetAllPackagesResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAllPackagesResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest GetAllPackagesResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetBurnMintFactoryResp parses an HTTP response from a GetBurnMintFactoryWithResponse call +func ParseGetBurnMintFactoryResp(rsp *http.Response) (*GetBurnMintFactoryResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetBurnMintFactoryResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest FactoryWithChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetBurnOfferCreateContextResp parses an HTTP response from a GetBurnOfferCreateContextWithResponse call +func ParseGetBurnOfferCreateContextResp(rsp *http.Response) (*GetBurnOfferCreateContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetBurnOfferCreateContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest FactoryWithChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetBurnOfferAcceptContextResp parses an HTTP response from a GetBurnOfferAcceptContextWithResponse call +func ParseGetBurnOfferAcceptContextResp(rsp *http.Response) (*GetBurnOfferAcceptContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetBurnOfferAcceptContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetBurnOfferCancelContextResp parses an HTTP response from a GetBurnOfferCancelContextWithResponse call +func ParseGetBurnOfferCancelContextResp(rsp *http.Response) (*GetBurnOfferCancelContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetBurnOfferCancelContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetBurnOfferRejectContextResp parses an HTTP response from a GetBurnOfferRejectContextWithResponse call +func ParseGetBurnOfferRejectContextResp(rsp *http.Response) (*GetBurnOfferRejectContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetBurnOfferRejectContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetBurnRequestCreateContextResp parses an HTTP response from a GetBurnRequestCreateContextWithResponse call +func ParseGetBurnRequestCreateContextResp(rsp *http.Response) (*GetBurnRequestCreateContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetBurnRequestCreateContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest FactoryWithChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetBurnRequestAcceptContextResp parses an HTTP response from a GetBurnRequestAcceptContextWithResponse call +func ParseGetBurnRequestAcceptContextResp(rsp *http.Response) (*GetBurnRequestAcceptContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetBurnRequestAcceptContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetBurnRequestCancelContextResp parses an HTTP response from a GetBurnRequestCancelContextWithResponse call +func ParseGetBurnRequestCancelContextResp(rsp *http.Response) (*GetBurnRequestCancelContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetBurnRequestCancelContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetBurnRequestRejectContextResp parses an HTTP response from a GetBurnRequestRejectContextWithResponse call +func ParseGetBurnRequestRejectContextResp(rsp *http.Response) (*GetBurnRequestRejectContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetBurnRequestRejectContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetMintOfferCreateContextResp parses an HTTP response from a GetMintOfferCreateContextWithResponse call +func ParseGetMintOfferCreateContextResp(rsp *http.Response) (*GetMintOfferCreateContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetMintOfferCreateContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest FactoryWithChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetMintOfferAcceptContextResp parses an HTTP response from a GetMintOfferAcceptContextWithResponse call +func ParseGetMintOfferAcceptContextResp(rsp *http.Response) (*GetMintOfferAcceptContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetMintOfferAcceptContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetMintOfferCancelContextResp parses an HTTP response from a GetMintOfferCancelContextWithResponse call +func ParseGetMintOfferCancelContextResp(rsp *http.Response) (*GetMintOfferCancelContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetMintOfferCancelContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetMintOfferRejectContextResp parses an HTTP response from a GetMintOfferRejectContextWithResponse call +func ParseGetMintOfferRejectContextResp(rsp *http.Response) (*GetMintOfferRejectContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetMintOfferRejectContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetMintRequestCreateContextResp parses an HTTP response from a GetMintRequestCreateContextWithResponse call +func ParseGetMintRequestCreateContextResp(rsp *http.Response) (*GetMintRequestCreateContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetMintRequestCreateContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest FactoryWithChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetMintRequestAcceptContextResp parses an HTTP response from a GetMintRequestAcceptContextWithResponse call +func ParseGetMintRequestAcceptContextResp(rsp *http.Response) (*GetMintRequestAcceptContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetMintRequestAcceptContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetMintRequestCancelContextResp parses an HTTP response from a GetMintRequestCancelContextWithResponse call +func ParseGetMintRequestCancelContextResp(rsp *http.Response) (*GetMintRequestCancelContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetMintRequestCancelContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetMintRequestRejectContextResp parses an HTTP response from a GetMintRequestRejectContextWithResponse call +func ParseGetMintRequestRejectContextResp(rsp *http.Response) (*GetMintRequestRejectContextResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetMintRequestRejectContextResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChoiceContext + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest N404 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseVerifyTransferProofResp parses an HTTP response from a VerifyTransferProofWithResponse call +func ParseVerifyTransferProofResp(rsp *http.Response) (*VerifyTransferProofResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &VerifyTransferProofResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest VerifyTransferProofResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest N400 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest N500 + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseIsLiveResp parses an HTTP response from a IsLiveWithResponse call +func ParseIsLiveResp(rsp *http.Response) (*IsLiveResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &IsLiveResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseIsReadyResp parses an HTTP response from a IsReadyWithResponse call +func ParseIsReadyResp(rsp *http.Response) (*IsReadyResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &IsReadyResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ServerInterface represents all server handlers. +type ServerInterface interface { + + // (GET /) + Root(c *gin.Context) + + // (POST /api/utilities/v0/contract/instrument-configuration) + GetInstrumentConfiguration(c *gin.Context) + + // (GET /api/utilities/v0/contract/instrument-configuration/all) + GetAllInstrumentConfigurations(c *gin.Context) + + // (GET /api/utilities/v0/openapi) + GetOpenApiSpec(c *gin.Context) + + // (GET /api/utilities/v0/operator) + GetOperator(c *gin.Context) + + // (GET /api/utilities/v0/package/all) + GetAllPackages(c *gin.Context) + + // (POST /api/utilities/v0/registry/burn-mint-instruction/v0/burn-mint-factory) + GetBurnMintFactory(c *gin.Context) + + // (POST /api/utilities/v0/registry/burn/v0/offer) + GetBurnOfferCreateContext(c *gin.Context) + + // (POST /api/utilities/v0/registry/burn/v0/offer/{burnOfferId}/choice-contexts/accept) + GetBurnOfferAcceptContext(c *gin.Context, burnOfferId string) + + // (POST /api/utilities/v0/registry/burn/v0/offer/{burnOfferId}/choice-contexts/cancel) + GetBurnOfferCancelContext(c *gin.Context, burnOfferId string) + + // (POST /api/utilities/v0/registry/burn/v0/offer/{burnOfferId}/choice-contexts/reject) + GetBurnOfferRejectContext(c *gin.Context, burnOfferId string) + + // (POST /api/utilities/v0/registry/burn/v0/request) + GetBurnRequestCreateContext(c *gin.Context) + + // (POST /api/utilities/v0/registry/burn/v0/request/{burnRequestId}/choice-contexts/accept) + GetBurnRequestAcceptContext(c *gin.Context, burnRequestId string) + + // (POST /api/utilities/v0/registry/burn/v0/request/{burnRequestId}/choice-contexts/cancel) + GetBurnRequestCancelContext(c *gin.Context, burnRequestId string) + + // (POST /api/utilities/v0/registry/burn/v0/request/{burnRequestId}/choice-contexts/reject) + GetBurnRequestRejectContext(c *gin.Context, burnRequestId string) + + // (POST /api/utilities/v0/registry/mint/v0/offer) + GetMintOfferCreateContext(c *gin.Context) + + // (POST /api/utilities/v0/registry/mint/v0/offer/{mintOfferId}/choice-contexts/accept) + GetMintOfferAcceptContext(c *gin.Context, mintOfferId string) + + // (POST /api/utilities/v0/registry/mint/v0/offer/{mintOfferId}/choice-contexts/cancel) + GetMintOfferCancelContext(c *gin.Context, mintOfferId string) + + // (POST /api/utilities/v0/registry/mint/v0/offer/{mintOfferId}/choice-contexts/reject) + GetMintOfferRejectContext(c *gin.Context, mintOfferId string) + + // (POST /api/utilities/v0/registry/mint/v0/request) + GetMintRequestCreateContext(c *gin.Context) + + // (POST /api/utilities/v0/registry/mint/v0/request/{mintRequestId}/choice-contexts/accept) + GetMintRequestAcceptContext(c *gin.Context, mintRequestId string) + + // (POST /api/utilities/v0/registry/mint/v0/request/{mintRequestId}/choice-contexts/cancel) + GetMintRequestCancelContext(c *gin.Context, mintRequestId string) + + // (POST /api/utilities/v0/registry/mint/v0/request/{mintRequestId}/choice-contexts/reject) + GetMintRequestRejectContext(c *gin.Context, mintRequestId string) + + // (POST /api/utilities/v0/registry/transfer/v0/proof) + VerifyTransferProof(c *gin.Context) + + // (GET /livez) + IsLive(c *gin.Context) + + // (GET /readyz) + IsReady(c *gin.Context) +} + +// ServerInterfaceWrapper converts contexts to parameters. +type ServerInterfaceWrapper struct { + Handler ServerInterface + HandlerMiddlewares []MiddlewareFunc + ErrorHandler func(*gin.Context, error, int) +} + +type MiddlewareFunc func(c *gin.Context) + +// Root operation middleware +func (siw *ServerInterfaceWrapper) Root(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.Root(c) +} + +// GetInstrumentConfiguration operation middleware +func (siw *ServerInterfaceWrapper) GetInstrumentConfiguration(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetInstrumentConfiguration(c) +} + +// GetAllInstrumentConfigurations operation middleware +func (siw *ServerInterfaceWrapper) GetAllInstrumentConfigurations(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetAllInstrumentConfigurations(c) +} + +// GetOpenApiSpec operation middleware +func (siw *ServerInterfaceWrapper) GetOpenApiSpec(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetOpenApiSpec(c) +} + +// GetOperator operation middleware +func (siw *ServerInterfaceWrapper) GetOperator(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetOperator(c) +} + +// GetAllPackages operation middleware +func (siw *ServerInterfaceWrapper) GetAllPackages(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetAllPackages(c) +} + +// GetBurnMintFactory operation middleware +func (siw *ServerInterfaceWrapper) GetBurnMintFactory(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetBurnMintFactory(c) +} + +// GetBurnOfferCreateContext operation middleware +func (siw *ServerInterfaceWrapper) GetBurnOfferCreateContext(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetBurnOfferCreateContext(c) +} + +// GetBurnOfferAcceptContext operation middleware +func (siw *ServerInterfaceWrapper) GetBurnOfferAcceptContext(c *gin.Context) { + + var err error + + // ------------- Path parameter "burnOfferId" ------------- + var burnOfferId string + + err = runtime.BindStyledParameterWithOptions("simple", "burnOfferId", c.Param("burnOfferId"), &burnOfferId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter burnOfferId: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetBurnOfferAcceptContext(c, burnOfferId) +} + +// GetBurnOfferCancelContext operation middleware +func (siw *ServerInterfaceWrapper) GetBurnOfferCancelContext(c *gin.Context) { + + var err error + + // ------------- Path parameter "burnOfferId" ------------- + var burnOfferId string + + err = runtime.BindStyledParameterWithOptions("simple", "burnOfferId", c.Param("burnOfferId"), &burnOfferId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter burnOfferId: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetBurnOfferCancelContext(c, burnOfferId) +} + +// GetBurnOfferRejectContext operation middleware +func (siw *ServerInterfaceWrapper) GetBurnOfferRejectContext(c *gin.Context) { + + var err error + + // ------------- Path parameter "burnOfferId" ------------- + var burnOfferId string + + err = runtime.BindStyledParameterWithOptions("simple", "burnOfferId", c.Param("burnOfferId"), &burnOfferId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter burnOfferId: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetBurnOfferRejectContext(c, burnOfferId) +} + +// GetBurnRequestCreateContext operation middleware +func (siw *ServerInterfaceWrapper) GetBurnRequestCreateContext(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetBurnRequestCreateContext(c) +} + +// GetBurnRequestAcceptContext operation middleware +func (siw *ServerInterfaceWrapper) GetBurnRequestAcceptContext(c *gin.Context) { + + var err error + + // ------------- Path parameter "burnRequestId" ------------- + var burnRequestId string + + err = runtime.BindStyledParameterWithOptions("simple", "burnRequestId", c.Param("burnRequestId"), &burnRequestId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter burnRequestId: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetBurnRequestAcceptContext(c, burnRequestId) +} + +// GetBurnRequestCancelContext operation middleware +func (siw *ServerInterfaceWrapper) GetBurnRequestCancelContext(c *gin.Context) { + + var err error + + // ------------- Path parameter "burnRequestId" ------------- + var burnRequestId string + + err = runtime.BindStyledParameterWithOptions("simple", "burnRequestId", c.Param("burnRequestId"), &burnRequestId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter burnRequestId: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetBurnRequestCancelContext(c, burnRequestId) +} + +// GetBurnRequestRejectContext operation middleware +func (siw *ServerInterfaceWrapper) GetBurnRequestRejectContext(c *gin.Context) { + + var err error + + // ------------- Path parameter "burnRequestId" ------------- + var burnRequestId string + + err = runtime.BindStyledParameterWithOptions("simple", "burnRequestId", c.Param("burnRequestId"), &burnRequestId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter burnRequestId: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetBurnRequestRejectContext(c, burnRequestId) +} + +// GetMintOfferCreateContext operation middleware +func (siw *ServerInterfaceWrapper) GetMintOfferCreateContext(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetMintOfferCreateContext(c) +} + +// GetMintOfferAcceptContext operation middleware +func (siw *ServerInterfaceWrapper) GetMintOfferAcceptContext(c *gin.Context) { + + var err error + + // ------------- Path parameter "mintOfferId" ------------- + var mintOfferId string + + err = runtime.BindStyledParameterWithOptions("simple", "mintOfferId", c.Param("mintOfferId"), &mintOfferId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter mintOfferId: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetMintOfferAcceptContext(c, mintOfferId) +} + +// GetMintOfferCancelContext operation middleware +func (siw *ServerInterfaceWrapper) GetMintOfferCancelContext(c *gin.Context) { + + var err error + + // ------------- Path parameter "mintOfferId" ------------- + var mintOfferId string + + err = runtime.BindStyledParameterWithOptions("simple", "mintOfferId", c.Param("mintOfferId"), &mintOfferId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter mintOfferId: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetMintOfferCancelContext(c, mintOfferId) +} + +// GetMintOfferRejectContext operation middleware +func (siw *ServerInterfaceWrapper) GetMintOfferRejectContext(c *gin.Context) { + + var err error + + // ------------- Path parameter "mintOfferId" ------------- + var mintOfferId string + + err = runtime.BindStyledParameterWithOptions("simple", "mintOfferId", c.Param("mintOfferId"), &mintOfferId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter mintOfferId: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetMintOfferRejectContext(c, mintOfferId) +} + +// GetMintRequestCreateContext operation middleware +func (siw *ServerInterfaceWrapper) GetMintRequestCreateContext(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetMintRequestCreateContext(c) +} + +// GetMintRequestAcceptContext operation middleware +func (siw *ServerInterfaceWrapper) GetMintRequestAcceptContext(c *gin.Context) { + + var err error + + // ------------- Path parameter "mintRequestId" ------------- + var mintRequestId string + + err = runtime.BindStyledParameterWithOptions("simple", "mintRequestId", c.Param("mintRequestId"), &mintRequestId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter mintRequestId: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetMintRequestAcceptContext(c, mintRequestId) +} + +// GetMintRequestCancelContext operation middleware +func (siw *ServerInterfaceWrapper) GetMintRequestCancelContext(c *gin.Context) { + + var err error + + // ------------- Path parameter "mintRequestId" ------------- + var mintRequestId string + + err = runtime.BindStyledParameterWithOptions("simple", "mintRequestId", c.Param("mintRequestId"), &mintRequestId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter mintRequestId: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetMintRequestCancelContext(c, mintRequestId) +} + +// GetMintRequestRejectContext operation middleware +func (siw *ServerInterfaceWrapper) GetMintRequestRejectContext(c *gin.Context) { + + var err error + + // ------------- Path parameter "mintRequestId" ------------- + var mintRequestId string + + err = runtime.BindStyledParameterWithOptions("simple", "mintRequestId", c.Param("mintRequestId"), &mintRequestId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter mintRequestId: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetMintRequestRejectContext(c, mintRequestId) +} + +// VerifyTransferProof operation middleware +func (siw *ServerInterfaceWrapper) VerifyTransferProof(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.VerifyTransferProof(c) +} + +// IsLive operation middleware +func (siw *ServerInterfaceWrapper) IsLive(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.IsLive(c) +} + +// IsReady operation middleware +func (siw *ServerInterfaceWrapper) IsReady(c *gin.Context) { + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.IsReady(c) +} + +// GinServerOptions provides options for the Gin server. +type GinServerOptions struct { + BaseURL string + Middlewares []MiddlewareFunc + ErrorHandler func(*gin.Context, error, int) +} + +// RegisterHandlers creates http.Handler with routing matching OpenAPI spec. +func RegisterHandlers(router gin.IRouter, si ServerInterface) { + RegisterHandlersWithOptions(router, si, GinServerOptions{}) +} + +// RegisterHandlersWithOptions creates http.Handler with additional options +func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options GinServerOptions) { + errorHandler := options.ErrorHandler + if errorHandler == nil { + errorHandler = func(c *gin.Context, err error, statusCode int) { + c.JSON(statusCode, gin.H{"msg": err.Error()}) + } + } + + wrapper := ServerInterfaceWrapper{ + Handler: si, + HandlerMiddlewares: options.Middlewares, + ErrorHandler: errorHandler, + } + + router.GET(options.BaseURL+"/", wrapper.Root) + router.POST(options.BaseURL+"/api/utilities/v0/contract/instrument-configuration", wrapper.GetInstrumentConfiguration) + router.GET(options.BaseURL+"/api/utilities/v0/contract/instrument-configuration/all", wrapper.GetAllInstrumentConfigurations) + router.GET(options.BaseURL+"/api/utilities/v0/openapi", wrapper.GetOpenApiSpec) + router.GET(options.BaseURL+"/api/utilities/v0/operator", wrapper.GetOperator) + router.GET(options.BaseURL+"/api/utilities/v0/package/all", wrapper.GetAllPackages) + router.POST(options.BaseURL+"/api/utilities/v0/registry/burn-mint-instruction/v0/burn-mint-factory", wrapper.GetBurnMintFactory) + router.POST(options.BaseURL+"/api/utilities/v0/registry/burn/v0/offer", wrapper.GetBurnOfferCreateContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/burn/v0/offer/:burnOfferId/choice-contexts/accept", wrapper.GetBurnOfferAcceptContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/burn/v0/offer/:burnOfferId/choice-contexts/cancel", wrapper.GetBurnOfferCancelContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/burn/v0/offer/:burnOfferId/choice-contexts/reject", wrapper.GetBurnOfferRejectContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/burn/v0/request", wrapper.GetBurnRequestCreateContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/burn/v0/request/:burnRequestId/choice-contexts/accept", wrapper.GetBurnRequestAcceptContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/burn/v0/request/:burnRequestId/choice-contexts/cancel", wrapper.GetBurnRequestCancelContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/burn/v0/request/:burnRequestId/choice-contexts/reject", wrapper.GetBurnRequestRejectContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/mint/v0/offer", wrapper.GetMintOfferCreateContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/mint/v0/offer/:mintOfferId/choice-contexts/accept", wrapper.GetMintOfferAcceptContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/mint/v0/offer/:mintOfferId/choice-contexts/cancel", wrapper.GetMintOfferCancelContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/mint/v0/offer/:mintOfferId/choice-contexts/reject", wrapper.GetMintOfferRejectContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/mint/v0/request", wrapper.GetMintRequestCreateContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/mint/v0/request/:mintRequestId/choice-contexts/accept", wrapper.GetMintRequestAcceptContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/mint/v0/request/:mintRequestId/choice-contexts/cancel", wrapper.GetMintRequestCancelContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/mint/v0/request/:mintRequestId/choice-contexts/reject", wrapper.GetMintRequestRejectContext) + router.POST(options.BaseURL+"/api/utilities/v0/registry/transfer/v0/proof", wrapper.VerifyTransferProof) + router.GET(options.BaseURL+"/livez", wrapper.IsLive) + router.GET(options.BaseURL+"/readyz", wrapper.IsReady) +} diff --git a/openapi/gen/daRegistry/generate.go b/openapi/gen/daRegistry/generate.go new file mode 100644 index 000000000..acd77ff8c --- /dev/null +++ b/openapi/gen/daRegistry/generate.go @@ -0,0 +1,3 @@ +package daRegistry + +//go:generate go tool oapi-codegen -config ./cfg.yaml ../../src/daRegistry/da-registry-backend-api.yaml diff --git a/openapi/gen/eds/ccip/ccip.gen.go b/openapi/gen/eds/ccip/ccip.gen.go index ecc290778..0a6dfd104 100644 --- a/openapi/gen/eds/ccip/ccip.gen.go +++ b/openapi/gen/eds/ccip/ccip.gen.go @@ -22,6 +22,9 @@ import ( type CCIPExecuteRequest struct { // EncodedMessage The CCIP message to be executed, encoded as a hex string. EncodedMessage string `json:"encodedMessage"` + + // Receiver The unique identifier of a party. + Receiver externalRef0.PartyId `json:"receiver"` } // CCIPExecuteResponse defines model for CCIPExecuteResponse. diff --git a/openapi/gen/eds/ccv/ccv.gen.go b/openapi/gen/eds/ccv/ccv.gen.go index 46874bbc3..718fb5ff4 100644 --- a/openapi/gen/eds/ccv/ccv.gen.go +++ b/openapi/gen/eds/ccv/ccv.gen.go @@ -22,6 +22,9 @@ import ( type CCVExecuteRequest struct { // EncodedMessage The CCIP message to be executed, encoded as a hex string. EncodedMessage string `json:"encodedMessage"` + + // Receiver The unique identifier of a party. + Receiver externalRef0.PartyId `json:"receiver"` } // CCVExecuteResponse defines model for CCVExecuteResponse. diff --git a/openapi/gen/eds/common/common.gen.go b/openapi/gen/eds/common/common.gen.go index 2fb0c125f..7d605b6ac 100644 --- a/openapi/gen/eds/common/common.gen.go +++ b/openapi/gen/eds/common/common.gen.go @@ -79,6 +79,9 @@ type Message struct { // Receiver The receiver of the message on the remote chain, encoded as a hex string. Receiver string `json:"receiver"` + // Sender The unique identifier of a party. + Sender PartyId `json:"sender"` + // TokenTransfer A token transfer to be included in the message, set to null if the message does not include a token transfer. TokenTransfer *TokenTransfer `json:"tokenTransfer,omitempty"` } @@ -105,7 +108,8 @@ type RawOrHashedInstrumentId struct { // TokenTransfer A token transfer to be included in the message, set to null if the message does not include a token transfer. type TokenTransfer struct { // Amount The decimal amount of the token to be transferred. - Amount string `json:"amount"` + Amount string `json:"amount"` + HoldingContractIds *[]ContractId `json:"holdingContractIds,omitempty"` // Token A globally unique identifier for instruments. Token InstrumentId `json:"token"` diff --git a/openapi/gen/eds/tokenpool/tokenpool.gen.go b/openapi/gen/eds/tokenpool/tokenpool.gen.go index 459658320..94e9a5f6c 100644 --- a/openapi/gen/eds/tokenpool/tokenpool.gen.go +++ b/openapi/gen/eds/tokenpool/tokenpool.gen.go @@ -22,6 +22,9 @@ import ( type TokenPoolExecuteRequest struct { // EncodedMessage The CCIP message to be executed, encoded as a hex string. EncodedMessage string `json:"encodedMessage"` + + // Receiver The unique identifier of a party. + Receiver externalRef0.PartyId `json:"receiver"` } // TokenPoolExecuteResponse defines model for TokenPoolExecuteResponse. diff --git a/openapi/src/daRegistry/da-registry-backend-api.yaml b/openapi/src/daRegistry/da-registry-backend-api.yaml new file mode 100644 index 000000000..d32fa010c --- /dev/null +++ b/openapi/src/daRegistry/da-registry-backend-api.yaml @@ -0,0 +1,1145 @@ +openapi: 3.0.0 +info: + title: Utilities API + description: Exposes technical information and contract data of the Utility App + version: 2.1.0 +tags: + - name: utility +servers: + - url: "http://localhost:8080" +paths: + /: + get: + tags: [common] + operationId: "root" + x-jvm-package: health + responses: + "200": + description: ok + /readyz: + get: + tags: [common] + operationId: "isReady" + x-jvm-package: health + responses: + "200": + description: ok + "503": + description: service unavailable + /livez: + get: + tags: [common] + operationId: "isLive" + x-jvm-package: health + responses: + "200": + description: ok + "503": + description: service unavailable + + /api/utilities/v0/openapi: + get: + tags: [operator] + operationId: "getOpenApiSpec" + x-jvm-package: utility + responses: + "200": + description: Returns the OpenApi specification + content: + application/octet-stream: + schema: + type: string + format: binary + "500": + description: OpenApi specification is not available + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + /api/utilities/v0/operator: + get: + tags: [operator] + operationId: "getOperator" + x-jvm-package: utility + responses: + "200": + description: Returns the operator party + content: + application/json: + schema: + $ref: "#/components/schemas/GetOperatorResponse" + "500": + description: Operator party is not available + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + /api/utilities/v0/package/all: + get: + tags: [operator] + operationId: "getAllPackages" + x-jvm-package: utility + responses: + "200": + description: Returns package information that are in use + content: + application/json: + schema: + "$ref": "#/components/schemas/GetAllPackagesResponse" + "500": + description: Operator party is not available + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + /api/utilities/v0/contract/instrument-configuration/all: + get: + tags: [operator] + operationId: "getAllInstrumentConfigurations" + x-jvm-package: utility + responses: + "200": + description: Returns all instrument configurations + content: + application/json: + schema: + $ref: "#/components/schemas/GetAllInstrumentConfigurationsResponse" + "500": + description: Operator party is not available + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + /api/utilities/v0/contract/instrument-configuration: + post: + tags: [operator] + operationId: "getInstrumentConfiguration" + x-jvm-package: utility + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/GetInstrumentConfigurationRequest" + responses: + "200": + description: Returns the instrument configuration + content: + application/json: + schema: + $ref: "#/components/schemas/GetInstrumentConfigurationResponse" + "404": + description: Instrument configuration not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "500": + description: Operator party is not available + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + /api/utilities/v0/registry/mint/v0/offer: + post: + tags: [registry] + operationId: "getMintOfferCreateContext" + x-jvm-package: registry + description: | + Get the factory and choice context for creating a mint offer. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/OfferMintRequest" + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/FactoryWithChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/mint/v0/request: + post: + tags: [registry] + operationId: "getMintRequestCreateContext" + x-jvm-package: registry + description: | + Get the factory and choice context for creating a mint request. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/RequestMintRequest" + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/FactoryWithChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/burn/v0/offer: + post: + tags: [registry] + operationId: "getBurnOfferCreateContext" + x-jvm-package: registry + description: | + Get the factory and choice context for creating a burn offer. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/OfferBurnRequest" + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/FactoryWithChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/burn/v0/request: + post: + tags: [registry] + operationId: "getBurnRequestCreateContext" + x-jvm-package: registry + description: | + Get the factory and choice context for creating a burn request. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/RequestBurnRequest" + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/FactoryWithChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/mint/v0/offer/{mintOfferId}/choice-contexts/accept: + post: + tags: [registry] + operationId: "getMintOfferAcceptContext" + x-jvm-package: registry + description: | + Get the choice context to accept and execute a mint offer. + parameters: + - name: mintOfferId + description: "The contract ID of the mint offer to accept." + in: path + required: true + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/ChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/mint/v0/offer/{mintOfferId}/choice-contexts/reject: + post: + tags: [registry] + operationId: "getMintOfferRejectContext" + x-jvm-package: registry + description: | + Get the choice context to reject a mint offer. + parameters: + - name: mintOfferId + description: "The contract ID of the mint offer to reject." + in: path + required: true + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/ChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/mint/v0/offer/{mintOfferId}/choice-contexts/cancel: + post: + tags: [registry] + operationId: "getMintOfferCancelContext" + x-jvm-package: registry + description: | + Get the choice context to cancel a mint offer. + parameters: + - name: mintOfferId + description: "The contract ID of the mint offer to cancel." + in: path + required: true + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/ChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/mint/v0/request/{mintRequestId}/choice-contexts/accept: + post: + tags: [registry] + operationId: "getMintRequestAcceptContext" + x-jvm-package: registry + description: | + Get the choice context to accept and execute a mint request. + parameters: + - name: mintRequestId + description: "The contract ID of the mint request to accept." + in: path + required: true + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/ChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/mint/v0/request/{mintRequestId}/choice-contexts/reject: + post: + tags: [registry] + operationId: "getMintRequestRejectContext" + x-jvm-package: registry + description: | + Get the choice context to reject a mint request. + parameters: + - name: mintRequestId + description: "The contract ID of the mint request to reject." + in: path + required: true + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/ChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/mint/v0/request/{mintRequestId}/choice-contexts/cancel: + post: + tags: [registry] + operationId: "getMintRequestCancelContext" + x-jvm-package: registry + description: | + Get the choice context to cancel a mint request. + parameters: + - name: mintRequestId + description: "The contract ID of the mint request to cancel." + in: path + required: true + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/ChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/burn/v0/offer/{burnOfferId}/choice-contexts/accept: + post: + tags: [registry] + operationId: "getBurnOfferAcceptContext" + x-jvm-package: registry + description: | + Get the choice context to accept and execute a burn offer. + parameters: + - name: burnOfferId + description: "The contract ID of the burn offer to accept." + in: path + required: true + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/ChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/burn/v0/offer/{burnOfferId}/choice-contexts/reject: + post: + tags: [registry] + operationId: "getBurnOfferRejectContext" + x-jvm-package: registry + description: | + Get the choice context to reject a burn offer. + parameters: + - name: burnOfferId + description: "The contract ID of the burn offer to reject." + in: path + required: true + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/ChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/burn/v0/offer/{burnOfferId}/choice-contexts/cancel: + post: + tags: [registry] + operationId: "getBurnOfferCancelContext" + x-jvm-package: registry + description: | + Get the choice context to cancel a burn offer. + parameters: + - name: burnOfferId + description: "The contract ID of the burn offer to cancel." + in: path + required: true + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/ChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/burn/v0/request/{burnRequestId}/choice-contexts/accept: + post: + tags: [registry] + operationId: "getBurnRequestAcceptContext" + x-jvm-package: registry + description: | + Get the choice context to accept and execute a burn request. + parameters: + - name: burnRequestId + description: "The contract ID of the burn request to accept." + in: path + required: true + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/ChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/burn/v0/request/{burnRequestId}/choice-contexts/reject: + post: + tags: [registry] + operationId: "getBurnRequestRejectContext" + x-jvm-package: registry + description: | + Get the choice context to reject a burn request. + parameters: + - name: burnRequestId + description: "The contract ID of the burn request to reject." + in: path + required: true + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/ChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/burn/v0/request/{burnRequestId}/choice-contexts/cancel: + post: + tags: [registry] + operationId: "getBurnRequestCancelContext" + x-jvm-package: registry + description: | + Get the choice context to cancel a burn request. + parameters: + - name: burnRequestId + description: "The contract ID of the burn request to cancel." + in: path + required: true + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/ChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/burn-mint-instruction/v0/burn-mint-factory: + post: + tags: [registry] + operationId: "getBurnMintFactory" + x-jvm-package: registry + description: | + Get the burn mint factory and choice context for burn and mint. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/GetBurnMintFactoryRequest" + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/FactoryWithChoiceContext" + "400": + $ref: "#/components/responses/400" + "404": + $ref: "#/components/responses/404" + "500": + $ref: "#/components/responses/500" + + /api/utilities/v0/registry/transfer/v0/proof: + post: + tags: [registry] + operationId: "verifyTransferProof" + x-jvm-package: registry + description: | + Verify the outcome of a transfer of Registry Utility assets on Canton. + + Given an UpdateID and a Transfer Object, the service looks up the corresponding + ledger transaction and verifies the transfer details against the on-chain events. + + The response status indicates the transfer outcome: + - `Success`: The transfer was executed in the referenced transaction + - `Pending`: The transfer instruction has been created but not yet settled + - `Failure`: The transfer instruction was rejected or withdrawn by one of the parties + + If none of the above conditions are met, if the provided transfer details do not match + the on-chain data, or if the original TransferInstruction contract cannot be retrieved, + a `400` is returned. No further diagnostic information is included in + the error response to prevent unintended disclosure of sensitive ledger data. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/VerifyTransferProofRequest" + responses: + "200": + description: | + Transfer proof verified. The `status` field indicates the transfer outcome + (`Success`, `Pending`, or `Failure`). See the endpoint description for details. + content: + application/json: + schema: + $ref: "#/components/schemas/VerifyTransferProofResponse" + "400": + $ref: "#/components/responses/400" + "500": + $ref: "#/components/responses/500" + +components: + responses: + "400": + description: "bad request" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "404": + description: "not found" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "500": + description: "Internal server error" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + securitySchemes: + BearerAuth: + type: http + scheme: bearer + schemas: + Error: + type: object + description: "A problem occurred with processing the request. For instance: syntactically invalid JSON body, missing required fields, etc." + required: + - error + - error_description + properties: + error: + description: An error code, e.g. invalid_token + type: string + default: unknown_error + error_description: + description: A description of the error + type: string + default: Something went wrong + + ContractMeta: + type: object + required: + - contractId + - templateId + properties: + createdAt: + type: string + format: date-time + contractId: + type: string + templateId: + type: string + synchronizerId: + type: string + description: Preferred synchronizer identifier for disclosed contracts and contract metadata. + domainId: + type: string + deprecated: true + description: Deprecated alias of synchronizerId kept for backward compatibility. + + DisclosedContract: + allOf: + - $ref: "#/components/schemas/ContractMeta" + - type: object + required: + - createdEventBlob + properties: + createdEventBlob: + type: string + description: The base64 encoded created event blob + + PartyCredentialRequirement: + type: object + required: + - issuer + - requiredClaims + properties: + issuer: + type: string + description: Required issuer of the credential + requiredClaims: + type: string + description: Required (property, value) pairs that the holder has to have claims for as a subject + items: + $ref: "#/components/schemas/CredentialClaim" + + CredentialClaim: + type: object + required: + - property + - value + properties: + property: + type: string + description: The property of the claim + value: + type: string + description: The value of the claim + + InstrumentIdentifier: + type: object + required: + - source + - id + - scheme + properties: + source: + description: The entity that originally created or issued the identifier. + type: string + id: + description: The identifier for the instrument + type: string + scheme: + description: The scheme or standard used for the identifier. + type: string + + GetOperatorResponse: + type: object + required: + - partyId + properties: + partyId: + type: string + description: The operator party id + + GetAllPackagesResponse: + type: object + required: + - packages + properties: + packages: + type: array + items: + $ref: "#/components/schemas/PackageDescriptor" + + PackageDescriptor: + type: object + description: Contains the package ids for a given package name + required: + - name + - id + properties: + name: + description: Name of the package + type: string + id: + description: Package ID + type: string + + GetInstrumentConfigurationRequest: + type: object + required: + - registrar + - instrumentIdentifier + properties: + registrar: + type: string + description: The registrar party id + instrumentIdentifier: + $ref: "#/components/schemas/InstrumentIdentifier" + + GetInstrumentConfigurationResponse: + $ref: "#/components/schemas/InstrumentConfiguration" + + GetAllInstrumentConfigurationsResponse: + type: object + required: + - instrumentConfigurations + properties: + instrumentConfigurations: + type: array + description: All instrument configurations + items: + $ref: "#/components/schemas/InstrumentConfiguration" + + InstrumentConfiguration: + type: object + required: + - contract + - payload + properties: + contract: + $ref: "#/components/schemas/ContractMeta" + payload: + $ref: "#/components/schemas/InstrumentConfigurationPayload" + + InstrumentConfigurationPayload: + type: object + required: + - operator + - provider + - registrar + - defaultIdentifier + - additionalIdentifiers + - issuerRequirements + - holderRequirements + properties: + operator: + type: string + description: The operator party id + provider: + type: string + description: The provider party id + registrar: + type: string + description: The registrar party id + defaultIdentifier: + $ref: "#/components/schemas/InstrumentIdentifier" + additionalIdentifiers: + type: array + description: Additional instrument identifiers + items: + $ref: "#/components/schemas/InstrumentIdentifier" + issuerRequirements: + type: array + description: Credential requirements to mint/burn a given asset + items: + $ref: "#/components/schemas/PartyCredentialRequirement" + holderRequirements: + type: array + description: Credential requirements to transfer/lock/unlock a given asset + items: + $ref: "#/components/schemas/PartyCredentialRequirement" + + TokenInformation: + type: object + required: + - access_token + properties: + id_token: + type: string + access_token: + type: string + + GetFactoryRequest: + type: object + required: + - choiceArguments + properties: + choiceArguments: + type: object + description: | + The arguments that are intended to be passed to the choice provided by the factory. + To avoid repeating the Daml type definitions, they are specified as JSON objects. + However the concrete format is given by how the choice arguments are encoded using the Daml JSON API + + The choice arguments are provided so that the registry can also provide choice-argument + specific contracts, e.g., the configuration for a specific instrument-id. + + FactoryWithChoiceContext: + description: | + A factory contract together with the choice context required to exercise the choice + provided by the factory. Typically used to implement the generic initiation of on-ledger workflows + via a Daml interface. + + Clients SHOULD avoid reusing the same `FactoryWithChoiceContext` for exercising multiple choices, + as the choice context MAY be specific to the choice being exercised. + type: object + required: + - factoryId + - choiceContext + properties: + factoryId: + description: "The contract ID of the contract of the factory which can be used to create instruction." + type: string + choiceContext: + $ref: "#/components/schemas/ChoiceContext" + + ChoiceContext: + description: | + The context required to exercise a choice on a contract via an interface. + Used to retrieve additional reference date that is passed in via disclosed contracts, + which are in turn referred to via their contract ID in the `choiceContextData`. + type: object + required: + - choiceContextData + - disclosedContracts + properties: + choiceContextData: + description: "The additional data to use when exercising the choice." + type: object + disclosedContracts: + description: | + The contracts that are required to be disclosed to the participant node for exercising + the choice. + type: array + items: + $ref: "#/components/schemas/DisclosedContract" + + RequestBurnRequest: + description: "The request to get the factory and choice context for creating a burn request." + type: object + required: + - holder + - holdingContractIds + - instrumentId + properties: + holder: + description: "The party whose holding will be burned." + type: string + holdingContractIds: + description: "Contract ids of Holdings to be used for the burn." + type: array + items: + type: string + instrumentId: + $ref: "#/components/schemas/InstrumentId" + + OfferBurnRequest: + description: "The request to get the factory and choice context for creating a burn offer." + type: object + required: + - holder + - instrumentId + properties: + holder: + description: "The party whose holding will be burned." + type: string + instrumentId: + $ref: "#/components/schemas/InstrumentId" + + RequestMintRequest: + description: "The request to get the factory and choice context for creating a mint request." + type: object + required: + - holder + - instrumentId + properties: + holder: + description: "The party for whom the holding will be minted." + type: string + instrumentId: + $ref: "#/components/schemas/InstrumentId" + + OfferMintRequest: + description: "The request to get the factory and choice context for creating a mint offer." + type: object + required: + - holder + - instrumentId + properties: + holder: + description: "The party for whom the holding will be minted." + type: string + instrumentId: + $ref: "#/components/schemas/InstrumentId" + + GetBurnMintFactoryRequest: + description: "The request to get the factory and choice context for burn and mint." + type: object + required: + - instrumentId + - inputHoldingCids + - outputs + properties: + instrumentId: + $ref: "#/components/schemas/InstrumentId" + inputHoldingCids: + description: "Contract ids of Holdings to be used for the burn." + type: array + items: + type: string + outputs: + description: "The list of specification of a holding to be minted." + type: array + items: + $ref: "#/components/schemas/MintOutput" + + MintOutput: + description: "The output to be minted." + type: object + required: + - owner + - amount + properties: + owner: + description: "The party for whom the holding will be minted." + type: string + amount: + description: "The amount to be minted." + type: string + + InstrumentId: + description: "The identifier of the instrument." + type: object + required: + - admin + - id + properties: + admin: + description: "The party administering the instrument." + type: string + id: + description: "The unique identifier of the instrument." + type: string + + VerifyTransferProofRequest: + description: "Request to verify the outcome of a transfer of Registry Utility assets on Canton." + type: object + required: + - updateId + - transfer + properties: + updateId: + description: | + For the two-step transfer workflow, specifies the most recent UpdateId. + If the transfer has completed its second step (accept, reject, or withdraw), + use the UpdateId associated with that action. Otherwise, use the UpdateId from the initial transfer offer. + type: string + transfer: + $ref: "#/components/schemas/TransferObject" + + TransferObject: + description: "The transfer payload containing transaction details known only to the sender and receiver." + type: object + required: + - sender + - receiver + - amount + - instrumentId + - requestedAt + - executeBefore + - inputHoldingCids + - meta + properties: + sender: + description: "The party ID of the transfer sender." + type: string + receiver: + description: "The party ID of the transfer receiver." + type: string + amount: + description: "The transfer amount as a decimal string." + type: string + example: "1.0000000000" + instrumentId: + $ref: "#/components/schemas/InstrumentId" + requestedAt: + description: "The timestamp when the transfer was requested." + type: string + format: date-time + executeBefore: + description: "The deadline by which the transfer must be executed." + type: string + format: date-time + inputHoldingCids: + description: "Contract IDs of the holdings used as inputs for the transfer." + type: array + items: + type: string + meta: + $ref: "#/components/schemas/TransferMeta" + + TransferMeta: + description: "Additional metadata associated with the transfer." + type: object + required: + - values + properties: + values: + description: "Arbitrary key-value metadata attached to the transfer." + type: object + additionalProperties: + type: string + + VerifyTransferProofResponse: + description: "The outcome of verifying a transfer proof." + type: object + required: + - status + properties: + status: + $ref: "#/components/schemas/TransferProofStatus" + + TransferProofStatus: + description: | + The status of the transfer proof verification: + - `Success`: The proof is verified and the transfer was successfully concluded + - `Failure`: The proof is verified, but the transfer did not successfully conclude. + - `Pending`: The transaction is still in progress (e.g., a transfer offer has been sent but not yet accepted in a two-step flow). + type: string + enum: + - Success + - Failure + - Pending \ No newline at end of file diff --git a/openapi/src/docker-compose.yaml b/openapi/src/docker-compose.yaml index 8ff94a201..4c91ad3bc 100644 --- a/openapi/src/docker-compose.yaml +++ b/openapi/src/docker-compose.yaml @@ -18,5 +18,6 @@ services: {url: '/openapi/eds/ccv/eds-ccv.yaml', name: 'EDS - CCV'}, {url: '/openapi/eds/executor/eds-executor.yaml', name: 'EDS - Executor'}, {url: '/openapi/eds/global/eds-global.yaml', name: 'EDS - Global'}, - {url: '/openapi/eds/tokenpool/eds-tokenpool.yaml', name: 'EDS - Token Pool'} + {url: '/openapi/eds/tokenpool/eds-tokenpool.yaml', name: 'EDS - Token Pool'}, + {url: '/openapi/daRegistry/da-registry-backend-api.yaml', name: 'DA Registry Backend API'} ]" \ No newline at end of file diff --git a/openapi/src/eds/ccip/eds-ccip.yaml b/openapi/src/eds/ccip/eds-ccip.yaml index 152963490..a4e25f76b 100644 --- a/openapi/src/eds/ccip/eds-ccip.yaml +++ b/openapi/src/eds/ccip/eds-ccip.yaml @@ -209,10 +209,13 @@ components: type: object required: - encodedMessage + - receiver properties: encodedMessage: type: string description: The CCIP message to be executed, encoded as a hex string. + receiver: + $ref: "../common/eds-common.yaml#/components/schemas/PartyId" CCIPExecuteResponse: type: object required: diff --git a/openapi/src/eds/ccv/eds-ccv.yaml b/openapi/src/eds/ccv/eds-ccv.yaml index 5d01668ff..019d547d5 100644 --- a/openapi/src/eds/ccv/eds-ccv.yaml +++ b/openapi/src/eds/ccv/eds-ccv.yaml @@ -119,10 +119,13 @@ components: type: object required: - encodedMessage + - receiver properties: encodedMessage: type: string description: The CCIP message to be executed, encoded as a hex string. + receiver: + $ref: "../common/eds-common.yaml#/components/schemas/PartyId" CCVExecuteResponse: type: object required: diff --git a/openapi/src/eds/common/eds-common.yaml b/openapi/src/eds/common/eds-common.yaml index 65eb41e20..1454ac157 100644 --- a/openapi/src/eds/common/eds-common.yaml +++ b/openapi/src/eds/common/eds-common.yaml @@ -109,6 +109,7 @@ components: description: A message to be sent from Canton. required: - destinationChainSelector + - sender - receiver - payload - feeToken @@ -118,6 +119,8 @@ components: destinationChainSelector: type: string description: The chain selector of the destination chain. + sender: + $ref: "#/components/schemas/PartyId" receiver: type: string description: The receiver of the message on the remote chain, encoded as a hex string. @@ -165,6 +168,10 @@ components: type: string description: The decimal amount of the token to be transferred. example: "77.77" + holdingContractIds: + type: array + items: + $ref: "#/components/schemas/ContractId" EDSBaseUrl: type: string diff --git a/openapi/src/eds/tokenpool/eds-tokenpool.yaml b/openapi/src/eds/tokenpool/eds-tokenpool.yaml index 164b83c72..c7800aa8f 100644 --- a/openapi/src/eds/tokenpool/eds-tokenpool.yaml +++ b/openapi/src/eds/tokenpool/eds-tokenpool.yaml @@ -124,10 +124,13 @@ components: type: object required: - encodedMessage + - receiver properties: encodedMessage: type: string description: The CCIP message to be executed, encoded as a hex string. + receiver: + $ref: "../common/eds-common.yaml#/components/schemas/PartyId" TokenPoolExecuteResponse: type: object required: diff --git a/testhelpers/eds/ccip.go b/testhelpers/eds/ccip.go index 4b47125c3..8052ce1ff 100644 --- a/testhelpers/eds/ccip.go +++ b/testhelpers/eds/ccip.go @@ -8,6 +8,8 @@ import ( apiv2 "github.com/digital-asset/dazl-client/v8/go/api/com/daml/ledger/api/v2" + "github.com/smartcontractkit/go-daml/pkg/types" + "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/splice/splice_api_token_metadata_v1" "github.com/smartcontractkit/chainlink-canton/contracts" oapiCCIP "github.com/smartcontractkit/chainlink-canton/openapi/gen/eds/ccip" @@ -127,9 +129,11 @@ func GetCCIPExecuteDisclosure( ctx context.Context, ccipAPIClient oapiCCIP.ClientWithResponsesInterface, encodedMessageHex string, + receiver types.PARTY, ) (*CCIPExecuteDisclosure, error) { resp, err := ccipAPIClient.PostCCIPExecuteWithResponse(ctx, oapiCCIP.CCIPExecuteRequest{ EncodedMessage: encodedMessageHex, + Receiver: string(receiver), }) if err != nil { return nil, fmt.Errorf("error calling CCIPExecute: %w", err) diff --git a/testhelpers/eds/ccv.go b/testhelpers/eds/ccv.go index a092b0132..fa777164e 100644 --- a/testhelpers/eds/ccv.go +++ b/testhelpers/eds/ccv.go @@ -7,6 +7,8 @@ import ( apiv2 "github.com/digital-asset/dazl-client/v8/go/api/com/daml/ledger/api/v2" + "github.com/smartcontractkit/go-daml/pkg/types" + "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/splice/splice_api_token_metadata_v1" "github.com/smartcontractkit/chainlink-canton/contracts" oapiCCV "github.com/smartcontractkit/chainlink-canton/openapi/gen/eds/ccv" @@ -25,9 +27,11 @@ func GetCCVExecuteDisclosure( ccvAPIClient oapiCCV.ClientWithResponsesInterface, encodedMessageHex string, ccvAddress contracts.InstanceAddress, + receiver types.PARTY, ) (*CCVExecuteDisclosure, error) { resp, err := ccvAPIClient.PostCCVExecuteWithResponse(ctx, ccvAddress.String(), oapiCCV.CCVExecuteRequest{ EncodedMessage: encodedMessageHex, + Receiver: string(receiver), }) if err != nil { return nil, fmt.Errorf("error calling CCVExecute: %w", err) diff --git a/testhelpers/eds/tokenPool.go b/testhelpers/eds/tokenPool.go index f7efebb03..83813632b 100644 --- a/testhelpers/eds/tokenPool.go +++ b/testhelpers/eds/tokenPool.go @@ -6,6 +6,8 @@ import ( apiv2 "github.com/digital-asset/dazl-client/v8/go/api/com/daml/ledger/api/v2" + "github.com/smartcontractkit/go-daml/pkg/types" + "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/splice/splice_api_token_metadata_v1" "github.com/smartcontractkit/chainlink-canton/contracts" oapiCommon "github.com/smartcontractkit/chainlink-canton/openapi/gen/eds/common" @@ -25,9 +27,11 @@ func GetTokenPoolExecuteDisclosure( tokenPoolAPIClient oapiTokenPool.ClientWithResponsesInterface, encodedMessageHex string, tokenPoolAddress contracts.InstanceAddress, + receiver types.PARTY, ) (*TokenPoolExecuteDisclosure, error) { resp, err := tokenPoolAPIClient.PostTokenPoolExecuteWithResponse(ctx, tokenPoolAddress.String(), oapiTokenPool.TokenPoolExecuteRequest{ EncodedMessage: encodedMessageHex, + Receiver: string(receiver), }) if err != nil { return nil, fmt.Errorf("error calling Token Pool Execute: %w", err)