Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions db/migrations/postgres/000028_add_tokenpool_fields.down.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
BEGIN;
DROP INDEX tokenpool_protocolid;
CREATE UNIQUE INDEX tokenpool_protocolid ON tokenpool(protocol_id);

ALTER TABLE tokenpool DROP COLUMN connector;
ALTER TABLE tokenpool DROP COLUMN symbol;
ALTER TABLE tokenpool DROP COLUMN message_id;
Expand Down
3 changes: 3 additions & 0 deletions db/migrations/postgres/000028_add_tokenpool_fields.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ DELETE FROM tokenpool;
ALTER TABLE tokenpool ADD COLUMN connector VARCHAR(64) NOT NULL;
ALTER TABLE tokenpool ADD COLUMN symbol VARCHAR(64);
ALTER TABLE tokenpool ADD COLUMN message_id UUID;

DROP INDEX tokenpool_protocolid;
CREATE UNIQUE INDEX tokenpool_protocolid ON tokenpool(connector,protocol_id);
COMMIT;
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
BEGIN;
DROP INDEX tokentransfer_protocolid;
CREATE UNIQUE INDEX tokentransfer_protocolid ON tokentransfer(protocol_id);

ALTER TABLE tokenaccount DROP COLUMN connector;
ALTER TABLE tokentransfer DROP COLUMN connector;
COMMIT;
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ UPDATE tokentransfer SET connector = pool.connector
ALTER TABLE tokenaccount ALTER COLUMN connector SET NOT NULL;
ALTER TABLE tokentransfer ALTER COLUMN connector SET NOT NULL;

DROP INDEX tokentransfer_protocolid;
CREATE UNIQUE INDEX tokentransfer_protocolid ON tokentransfer(connector,protocol_id);

COMMIT;
3 changes: 3 additions & 0 deletions db/migrations/postgres/000044_add_tokenpool_state.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BEGIN;
ALTER TABLE tokenpool DROP COLUMN state;
COMMIT;
5 changes: 5 additions & 0 deletions db/migrations/postgres/000044_add_tokenpool_state.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BEGIN;
ALTER TABLE tokenpool ADD COLUMN state VARCHAR(64);
UPDATE tokenpool SET state='unknown';
ALTER TABLE tokenpool ALTER COLUMN state SET NOT NULL;
COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BEGIN;
ALTER TABLE tokentransfer DROP COLUMN message_id;
COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BEGIN;

ALTER TABLE tokentransfer ADD COLUMN message_id UUID;

UPDATE tokentransfer SET message_id = message.id
FROM (SELECT hash, id FROM messages) AS message
WHERE tokentransfer.message_hash = message.hash;

COMMIT;
3 changes: 3 additions & 0 deletions db/migrations/sqlite/000028_add_tokenpool_fields.down.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
DROP INDEX tokenpool_protocolid;
CREATE UNIQUE INDEX tokenpool_protocolid ON tokenpool(protocol_id);

ALTER TABLE tokenpool DROP COLUMN connector;
ALTER TABLE tokenpool DROP COLUMN symbol;
ALTER TABLE tokenpool DROP COLUMN message_id;
3 changes: 3 additions & 0 deletions db/migrations/sqlite/000028_add_tokenpool_fields.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ DELETE FROM tokenpool;
ALTER TABLE tokenpool ADD COLUMN connector VARCHAR(64) NOT NULL;
ALTER TABLE tokenpool ADD COLUMN symbol VARCHAR(64);
ALTER TABLE tokenpool ADD COLUMN message_id UUID;

DROP INDEX tokenpool_protocolid;
CREATE UNIQUE INDEX tokenpool_protocolid ON tokenpool(connector,protocol_id);
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
DROP INDEX tokentransfer_protocolid;
CREATE UNIQUE INDEX tokentransfer_protocolid ON tokentransfer(protocol_id);

ALTER TABLE tokenaccount DROP COLUMN connector;
ALTER TABLE tokentransfer DROP COLUMN connector;
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ UPDATE tokenaccount SET connector = pool.connector
UPDATE tokentransfer SET connector = pool.connector
FROM (SELECT protocol_id, connector FROM tokenpool) AS pool
WHERE tokentransfer.pool_protocol_id = pool.protocol_id;

DROP INDEX tokentransfer_protocolid;
CREATE UNIQUE INDEX tokentransfer_protocolid ON tokentransfer(connector,protocol_id);
1 change: 1 addition & 0 deletions db/migrations/sqlite/000044_add_tokenpool_state.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE tokenpool DROP COLUMN state;
2 changes: 2 additions & 0 deletions db/migrations/sqlite/000044_add_tokenpool_state.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE tokenpool ADD COLUMN state VARCHAR(64);
UPDATE tokenpool SET state="unknown";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE tokentransfer DROP COLUMN message_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE tokentransfer ADD COLUMN message_id UUID;

UPDATE tokentransfer SET message_id = message.id
FROM (SELECT hash, id FROM messages) AS message
WHERE tokentransfer.message_hash = message.hash;
51 changes: 51 additions & 0 deletions docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4197,6 +4197,11 @@ paths:
name: standard
schema:
type: string
- description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^'
in: query
name: state
schema:
type: string
- description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^'
in: query
name: symbol
Expand Down Expand Up @@ -4266,6 +4271,8 @@ paths:
type: string
standard:
type: string
state:
type: string
symbol:
type: string
tx:
Expand Down Expand Up @@ -4355,6 +4362,8 @@ paths:
type: string
standard:
type: string
state:
type: string
symbol:
type: string
tx:
Expand Down Expand Up @@ -4390,6 +4399,8 @@ paths:
type: string
standard:
type: string
state:
type: string
symbol:
type: string
tx:
Expand Down Expand Up @@ -4460,6 +4471,8 @@ paths:
type: string
standard:
type: string
state:
type: string
symbol:
type: string
tx:
Expand Down Expand Up @@ -4759,6 +4772,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -4793,6 +4807,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -4976,6 +4991,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -5010,6 +5026,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -5094,6 +5111,11 @@ paths:
name: localid
schema:
type: string
- description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^'
in: query
name: message
schema:
type: string
- description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^'
in: query
name: messagehash
Expand Down Expand Up @@ -5174,6 +5196,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -5357,6 +5380,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -5391,6 +5415,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -5881,6 +5906,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -5915,6 +5941,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -6118,6 +6145,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -6152,6 +6180,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -6238,6 +6267,11 @@ paths:
name: standard
schema:
type: string
- description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^'
in: query
name: state
schema:
type: string
- description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^'
in: query
name: symbol
Expand Down Expand Up @@ -6307,6 +6341,8 @@ paths:
type: string
standard:
type: string
state:
type: string
symbol:
type: string
tx:
Expand Down Expand Up @@ -6391,6 +6427,8 @@ paths:
type: string
standard:
type: string
state:
type: string
symbol:
type: string
tx:
Expand Down Expand Up @@ -6426,6 +6464,8 @@ paths:
type: string
standard:
type: string
state:
type: string
symbol:
type: string
tx:
Expand Down Expand Up @@ -6489,6 +6529,8 @@ paths:
type: string
standard:
type: string
state:
type: string
symbol:
type: string
tx:
Expand Down Expand Up @@ -6557,6 +6599,11 @@ paths:
name: localid
schema:
type: string
- description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^'
in: query
name: message
schema:
type: string
- description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^'
in: query
name: messagehash
Expand Down Expand Up @@ -6637,6 +6684,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -6807,6 +6855,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -6841,6 +6890,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down Expand Up @@ -6903,6 +6953,7 @@ paths:
key:
type: string
localId: {}
message: {}
messageHash: {}
namespace:
type: string
Expand Down
2 changes: 1 addition & 1 deletion internal/apiserver/route_post_token_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var postTokenPool = &oapispec.Route{
FilterFactory: nil,
Description: i18n.MsgTBD,
JSONInputValue: func() interface{} { return &fftypes.TokenPool{} },
JSONInputMask: []string{"ID", "Namespace", "Standard", "ProtocolID", "TX", "Message", "Created"},
JSONInputMask: []string{"ID", "Namespace", "Standard", "ProtocolID", "TX", "Message", "State", "Created"},
JSONOutputValue: func() interface{} { return &fftypes.TokenPool{} },
JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK},
JSONHandler: func(r *oapispec.APIRequest) (output interface{}, err error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/apiserver/route_post_token_pool_by_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var postTokenPoolByType = &oapispec.Route{
FilterFactory: nil,
Description: i18n.MsgTBD,
JSONInputValue: func() interface{} { return &fftypes.TokenPool{} },
JSONInputMask: []string{"ID", "Namespace", "Standard", "ProtocolID", "TX", "Connector", "Message", "Created"},
JSONInputMask: []string{"ID", "Namespace", "Standard", "ProtocolID", "TX", "Connector", "Message", "State", "Created"},
JSONOutputValue: func() interface{} { return &fftypes.TokenPool{} },
JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK},
JSONHandler: func(r *oapispec.APIRequest) (output interface{}, err error) {
Expand Down
5 changes: 1 addition & 4 deletions internal/assets/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ import (

type Manager interface {
CreateTokenPool(ctx context.Context, ns string, pool *fftypes.TokenPool, waitConfirm bool) (*fftypes.TokenPool, error)
ActivateTokenPool(ctx context.Context, pool *fftypes.TokenPool, tx *fftypes.Transaction) error
GetTokenPools(ctx context.Context, ns string, filter database.AndFilter) ([]*fftypes.TokenPool, *database.FilterResult, error)
GetTokenPool(ctx context.Context, ns, connector, poolName string) (*fftypes.TokenPool, error)
GetTokenPoolByNameOrID(ctx context.Context, ns string, poolNameOrID string) (*fftypes.TokenPool, error)
ValidateTokenPoolTx(ctx context.Context, pool *fftypes.TokenPool, protocolTxID string) error

GetTokenBalances(ctx context.Context, ns string, filter database.AndFilter) ([]*fftypes.TokenBalance, *database.FilterResult, error)
GetTokenAccounts(ctx context.Context, ns string, filter database.AndFilter) ([]*fftypes.TokenAccount, *database.FilterResult, error)
Expand All @@ -55,9 +55,6 @@ type Manager interface {

GetTokenConnectors(ctx context.Context, ns string) ([]*fftypes.TokenConnector, error)

// Bound token callbacks
TokenPoolCreated(ti tokens.Plugin, pool *fftypes.TokenPool, protocolTxID string, additionalInfo fftypes.JSONObject) error

// Deprecated
CreateTokenPoolByType(ctx context.Context, ns, connector string, pool *fftypes.TokenPool, waitConfirm bool) (*fftypes.TokenPool, error)
GetTokenPoolsByType(ctx context.Context, ns, connector string, filter database.AndFilter) ([]*fftypes.TokenPool, *database.FilterResult, error)
Expand Down
Loading