wharfkit / antelope

Core types, client interfaces, and other tools for working with Antelope-based blockchains.
Other
44 stars 23 forks source link

Add call for v1/chain/get_producer_schedule #55

Closed aaroncox closed 1 year ago

aaroncox commented 1 year ago

We need to wrap a call around this endpoint:

https://eos.greymass.com/v1/chain/get_producer_schedule

It returns an ordered schedule at the time of the call containing the producer and their signing authority. Should be relatively easy to type and return the response.

Example response:

{
    "active": {
        "version": 2066,
        "producers": [
            {
                "producer_name": "atticlabeosb",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS7PfA3A4UdfMu2wKbuXdbHn8EWAxbMnFoFWui4X2zsr2oPwdQJP",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "aus1genereos",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS6on4KsoQ3cjhXLixNQxB3jwYhmUhNK9rKTABdmBBZWbfNmhTeU",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "big.one",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS8MpYyXwn3DLqk9Y9XTHYcd6wGGijNqJefFoQEwEoXTq1awZ42w",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "binancestake",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS7unwwVJfmKonrT6Gj46LDiNUPpFhpPALpTe2eofmFeoG74bKKn",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "bitfinexeos1",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS4tkw7LgtURT3dvG3kQ4D1sg3aAtPDymmoatpuFkQMc7wzZdKxc",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "blockpooleos",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS61FDJz3GC42GhaPSsmKh7SxuesyZhjm7hBwBKqN52v1HukEqBu",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "bp.defi",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS5BoXgRJwL7JFvKnV64Q3Ha3ux6x2cP8nnhU9NVrRkyrhPC3m5b",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "eosasia11111",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS76gG6ATpqfVf5KrVjh3f4JAa4EKzAwWabTucNQ4Xv2TmVAj9bN",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "eoscannonchn",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS73cTi9V7PNg4ujW5QzoTfRSdhH44MPiUJkUV6m3oGwj7RX7kML",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "eoseouldotio",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS6SSA4gYCSZ3q9NWpxGsYDv5MWjSwKseyq25RRZexwj8EM6YHDa",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "eosflytomars",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS6Agpfp38bTyRjJDmB4Qb1EpQSq7wnEAsALXgXE7KFSzKjokkFD",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "eosinfstones",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS6CSvGzNhNxVYbcnWSuheNcfzjGeGBY9trR4YAJ4Yvakq4oCh6y",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "eosiosg11111",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS7zVBQMhV7dZ5zRQwBgDmmbFCHA6YcmwW6Dq5CePGpqLR1ZsVAc",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "eoslaomaocom",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS8QgURqo875qu3a8vgZ58qBeu2cTehe9zAWRfpdCXAQipicu1Fi",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "eosnationftw",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS8L12yBrtx7mpewHmjwgJeNb2aLaeQdoDgMW82dzDSu17ec2XNL",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "hashfineosio",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS7jSfvStvbKDmGvQdtrQsCyNkWczXfvh6CHmBVmeypJyHsUrMqj",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "ivote4eosusa",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS6KzD4YVbuXV5uBH5d4Ay4sTzuQk88ivmnWfJPLoo6SFrX6iyqj",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "newdex.bp",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS688SnH8tQ7NiyhamiCzWXAGPDLF9S7K8ga79UBHKFgjS1MhqhB",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "okcapitalbp1",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS6NqWZ1i9KSNoeBiby6Nmf1seAbEfhvrDoCbwSi1hV4cuqqnYRP",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "starteosiobp",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS4wZZXm994byKANLuwHD6tV3R3Mu3ktc41aSVXCBaGnXJZJ4pwF",
                                "weight": 1
                            }
                        ]
                    }
                ]
            },
            {
                "producer_name": "whaleex.com",
                "authority": [
                    0,
                    {
                        "threshold": 1,
                        "keys": [
                            {
                                "key": "EOS88EGcFghfQJER1mDaEe4kDJ7MGDoPmXQfA7q2QMTLLqiYP1UQR",
                                "weight": 1
                            }
                        ]
                    }
                ]
            }
        ]
    },
    "pending": null,
    "proposed": null
}
jdheeter commented 1 year ago

I found that most of the types are already defined in your library but not exported as far as I can tell.

// copied from eosio-core
interface ActiveScheduleProducerAuthority extends Struct {
  producer_name:Name
  authority:any
}
interface ActiveScheduleProducer extends Struct {
  producer_name:Name
  authority:ActiveScheduleProducerAuthority
}
interface ActiveSchedule extends Struct {
  version:UInt32
  producers:ActiveScheduleProducer[]
}

// I made this one
interface GetProducerScheduleResponse {
  active:ActiveSchedule
  pending:any
  proposed:any
}
aaroncox commented 1 year ago

Released in 0.6.11