Skip to content

Commit

Permalink
fix graphql errors
Browse files Browse the repository at this point in the history
  • Loading branch information
calvwang9 committed Dec 24, 2024
1 parent 490a247 commit eb844c0
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
75 changes: 75 additions & 0 deletions core/web/resolver/feeds_manager_chain_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,81 @@ func Test_CreateFeedsManagerChainConfig(t *testing.T) {
}
}`,
},
{
name: "success Tron",
authenticated: true,
before: func(ctx context.Context, f *gqlTestFramework) {
f.App.On("GetFeedsService").Return(f.Mocks.feedsSvc)
f.Mocks.feedsSvc.On("CreateChainConfig", mock.Anything, feeds.ChainConfig{
FeedsManagerID: mgrID,
ChainType: feeds.ChainTypeTron,
ChainID: chainID,
AccountAddress: accountAddr,
AccountAddressPublicKey: null.StringFrom(acctAddrPubKey),
AdminAddress: adminAddr,
FluxMonitorConfig: feeds.FluxMonitorConfig{
Enabled: false,
},
OCR1Config: feeds.OCR1Config{
Enabled: true,
P2PPeerID: peerID,
KeyBundleID: keyBundleID,
},
OCR2Config: feeds.OCR2ConfigModel{
Enabled: true,
P2PPeerID: peerID,
KeyBundleID: keyBundleID,
ForwarderAddress: null.StringFrom(forwarderAddr),
Plugins: feeds.Plugins{
Commit: true,
Execute: true,
Median: false,
Mercury: true,
Rebalancer: true,
},
},
}).Return(cfgID, nil)
f.Mocks.feedsSvc.On("GetChainConfig", mock.Anything, cfgID).Return(&feeds.ChainConfig{
ID: cfgID,
ChainType: feeds.ChainTypeTron,
ChainID: chainID,
AccountAddress: accountAddr,
AccountAddressPublicKey: null.StringFrom(acctAddrPubKey),
AdminAddress: adminAddr,
FluxMonitorConfig: feeds.FluxMonitorConfig{
Enabled: false,
},
OCR1Config: feeds.OCR1Config{
Enabled: true,
P2PPeerID: peerID,
KeyBundleID: keyBundleID,
},
OCR2Config: feeds.OCR2ConfigModel{
Enabled: true,
P2PPeerID: peerID,
KeyBundleID: keyBundleID,
ForwarderAddress: null.StringFrom(forwarderAddr),
Plugins: feeds.Plugins{
Commit: true,
Execute: true,
Median: false,
Mercury: true,
Rebalancer: true,
},
},
}, nil)
},
query: mutation,
variables: withVariables("TRON"),
result: `
{
"createFeedsManagerChainConfig": {
"chainConfig": {
"id": "1"
}
}
}`,
},
{
name: "create call not found",
authenticated: true,
Expand Down
6 changes: 6 additions & 0 deletions core/web/resolver/ocr2_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const (
OCR2ChainTypeStarkNet = "STARKNET"
// OCRChainTypeAptos defines OCR Aptos Chain Type
OCRChainTypeAptos = "APTOS"
// OCRChainTypeTron defines OCR2 Tron Chain Type
OCRChainTypeTron = "TRON"
)

// ToOCR2ChainType turns a valid string into a OCR2ChainType
Expand All @@ -42,6 +44,8 @@ func ToOCR2ChainType(s string) (OCR2ChainType, error) {
return OCR2ChainTypeStarkNet, nil
case string(chaintype.Aptos):
return OCRChainTypeAptos, nil
case string(chaintype.Tron):
return OCRChainTypeTron, nil
default:
return "", errors.New("unknown ocr2 chain type")
}
Expand All @@ -60,6 +64,8 @@ func FromOCR2ChainType(ct OCR2ChainType) string {
return string(chaintype.StarkNet)
case OCRChainTypeAptos:
return string(chaintype.Aptos)
case OCRChainTypeTron:
return string(chaintype.Tron)
default:
return strings.ToLower(string(ct))
}
Expand Down
13 changes: 13 additions & 0 deletions core/web/resolver/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,19 @@ func (r *Resolver) StarkNetKeys(ctx context.Context) (*StarkNetKeysPayloadResolv
return NewStarkNetKeysPayload(keys), nil
}

func (r *Resolver) TronKeys(ctx context.Context) (*TronKeysPayloadResolver, error) {
if err := authenticateUser(ctx); err != nil {
return nil, err
}

keys, err := r.App.GetKeyStore().Tron().GetAll()
if err != nil {
return nil, err
}

return NewTronKeysPayload(keys), nil
}

func (r *Resolver) SQLLogging(ctx context.Context) (*GetSQLLoggingPayloadResolver, error) {
if err := authenticateUser(ctx); err != nil {
return nil, err
Expand Down

0 comments on commit eb844c0

Please sign in to comment.