diff --git a/docs/design/legacy-identifiers-support.md b/docs/design/legacy-identifiers-support.md index 5b51ede1..3b1c578e 100644 --- a/docs/design/legacy-identifiers-support.md +++ b/docs/design/legacy-identifiers-support.md @@ -31,7 +31,7 @@ So that legacy DID can be associated with a new `did:ethr` and we can only use ` bytes32 sigS, string calldata identifier, bytes32 ed25519Key, - bytes calldata ed25518Signature + bytes calldata ed25519Signature ) // check signatures didMapping[identifier] = identity; diff --git a/docs/migration/migration.md b/docs/migration/migration.md index 3bb7d53a..293b9635 100644 --- a/docs/migration/migration.md +++ b/docs/migration/migration.md @@ -105,11 +105,11 @@ Issuer need to run migration tool manually (on the machine containing Indy Walle * `contracts` - specifications for contracts deployed on the network * `signer` - transactions signer 2. DID ownership moving to Besu Ledger: - 1. Issuer create Ed25518 key (with seed) in the Besu wallet + 1. Issuer create Ed25519 key (with seed) in the Besu wallet 2. Issuer create a new Secp256k1 keypair in Besu wallet 3. Issuer publish Secp256k1 key to Indy ledger using ATTRIB transaction: `{ "besu": { "key": secp256k1_key } }` * Now Besu Secp256k1 key is associated with the Issuer DID which is published on the Indy Ledger. - * ATTRIB transaction is signed with Ed25518 key. No signature request for `secp256k1_key`. + * ATTRIB transaction is signed with Ed25519 key. No signature request for `secp256k1_key`. 3. Issuer build DID Document which will include: * DID - fully qualified form should be used: `did:besu:network:` of DID which was published as NYM transaction to Indy Ledger * Two Verification Methods must be included: diff --git a/network/config/besu/genesis.json b/network/config/besu/genesis.json index e1da75ff..b0c5d961 100644 --- a/network/config/besu/genesis.json +++ b/network/config/besu/genesis.json @@ -226,12 +226,12 @@ "0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000019999", "0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000006666", "f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00": "0x0000000000000000000000000000000000000000000000000000000000000001", - "360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000a6d35f8e0f5f9790c4ca1cd875a3c323258336cb" + "360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000e7088f06ea5b03450396bfa213a34bc6f6dc1b8c" } }, - "0xa6d35f8e0f5f9790c4ca1cd875a3c323258336cb": { + "0xe7088f06ea5b03450396bfa213a34bc6f6dc1b8c": { "comment": "Implementation: Smart contract to store mapping of legacy identifiers to new one", - "code": "0x6080604052600436106100915760003560e01c80639a3265d9116100595780639a3265d914610140578063ad3cb1cc14610160578063c0c53b8b14610191578063c612ab58146101b1578063d924aedb146101d157600080fd5b80634f1ef2861461009657806352d1902d146100ab57806353aac465146100d35780637223460a146100f357806393a8c74214610113575b600080fd5b6100a96100a4366004612326565b6101f1565b005b3480156100b757600080fd5b506100c0610210565b6040519081526020015b60405180910390f35b3480156100df57600080fd5b506100a96100ee3660046123d9565b61022d565b3480156100ff57600080fd5b506100a961010e3660046124b7565b6102ee565b34801561011f57600080fd5b5061013361012e366004612587565b6103a8565b6040516100ca919061261f565b34801561014c57600080fd5b506100a961015b366004612632565b61044d565b34801561016c57600080fd5b50610133604051806040016040528060058152602001640352e302e360dc1b81525081565b34801561019d57600080fd5b506100a96101ac3660046126e5565b610468565b3480156101bd57600080fd5b506101336101cc366004612587565b61057c565b3480156101dd57600080fd5b506100a96101ec366004612728565b6105a0565b6101f96105b9565b61020282610660565b61020c82826106c6565b5050565b600061021a61078d565b50600080516020612c4f83398151915290565b6000601960f81b600060f81b308e8b8b8b8b8b8b8b60405160200161025c9b9a999897969594939291906127d2565b60408051601f1981840301815282825280516020918201206000845290830180835281905260ff8e1691830191909152606082018c9052608082018b905291506102e0908d9060019060a0016020604051602081039080840390855afa1580156102ca573d6000803e3d6000fd5b505050602060405103518a8a8a8a8a8a8a6107d6565b505050505050505050505050565b60405160009061031890601960f81b90839030908f908c908c908c908c908c908c90602001612864565b60408051601f1981840301815282825280516020918201206000845290830180835281905260ff8d1691830191909152606082018b9052608082018a9052915061039b908c9060019060a0016020604051602081039080840390855afa158015610386573d6000803e3d6000fd5b50505060206040510351898989898989610ad5565b5050505050505050505050565b8051602081830181018051600382529282019190930120915280546103cc906128fa565b80601f01602080910402602001604051908101604052809291908181526020018280546103f8906128fa565b80156104455780601f1061041a57610100808354040283529160200191610445565b820191906000526020600020905b81548152906001019060200180831161042857829003601f168201915b505050505081565b61045e8833898989898989896107d6565b5050505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805460019190600160401b900460ff16806104b1575080546001600160401b03808416911610155b156104cf5760405163f92ee8a960e01b815260040160405180910390fd5b805468ffffffffffffffffff19166001600160401b03831617600160401b1781556104f985610e0e565b600180546001600160a01b038681166001600160a01b0319928316179092556002805492861692909116919091179055805468ff0000000000000000191681556040516001600160401b03831681527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050505050565b8051602081830181018051600482529282019190930120915280546103cc906128fa565b6105b08733888888888888610ad5565b50505050505050565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148061064057507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610634600080516020612c4f833981519152546001600160a01b031690565b6001600160a01b031614155b1561065e5760405163703e46dd60e11b815260040160405180910390fd5b565b60005460405163574a81d760e01b81523060048201526001600160a01b0383811660248301529091169063574a81d79060440160006040518083038186803b1580156106ab57600080fd5b505afa1580156106bf573d6000803e3d6000fd5b5050505050565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015610720575060408051601f3d908101601f1916820190925261071d9181019061292e565b60015b61074d57604051634c9c8ce360e01b81526001600160a01b03831660048201526024015b60405180910390fd5b600080516020612c4f833981519152811461077e57604051632a87526960e21b815260048101829052602401610744565b6107888383610e38565b505050565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461065e5760405163703e46dd60e11b815260040160405180910390fd5b8888806001600160a01b0316826001600160a01b03161461081d576040516316343f1760e31b81526001600160a01b03808316600483015283166024820152604401610744565b6002546040516301daf29b60e21b81523360048201526001600160a01b039091169063076bca6c9060240160006040518083038186803b15801561086057600080fd5b505afa158015610874573d6000803e3d6000fd5b5050505061093961092c60038b8b604051610890929190612947565b908152602001604051809103902080546108a9906128fa565b80601f01602080910402602001604051908101604052809291908181526020018280546108d5906128fa565b80156109225780601f106108f757610100808354040283529160200191610922565b820191906000526020600020905b81548152906001019060200180831161090557829003601f168201915b5050505050610e8e565b6001600160801b03161590565b61095a578888604051630ab7bdc760e21b8152600401610744929190612980565b846001600160801b0319166109a48a8a8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e9f92505050565b6109ad90612994565b6001600160801b031916146109db57848989604051630876c99d60e21b8152600401610744939291906129cb565b610a26610a1d88888080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610eaa92505050565b60200151610ff5565b6001600160a01b03168b6001600160a01b031614610a5b578686604051631859e3bb60e11b8152600401610744929190612980565b868660038b8b604051610a6f929190612947565b90815260200160405180910390209182610a8a929190612a35565b507ff214be33ffacf63cd5f2d1636bef433e47c400b94d565c786049bfa836c20e1989898989604051610ac09493929190612af4565b60405180910390a15050505050505050505050565b8787806001600160a01b0316826001600160a01b031614610b1c576040516316343f1760e31b81526001600160a01b03808316600483015283166024820152604401610744565b6002546040516301daf29b60e21b81523360048201526001600160a01b039091169063076bca6c9060240160006040518083038186803b158015610b5f57600080fd5b505afa158015610b73573d6000803e3d6000fd5b5050505060048686604051610b89929190612947565b90815260200160405180910390208054610ba2906128fa565b159050610bc65785856040516327ef3c3d60e01b8152600401610744929190612980565b610bde61092c60038a8a604051610890929190612947565b15610c0057858560405163a54e9cfb60e01b8152600401610744929190612980565b6000610cb6610a1d60038b8b604051610c1a929190612947565b90815260200160405180910390208054610c33906128fa565b80601f0160208091040260200160405190810160405280929190818152602001828054610c5f906128fa565b8015610cac5780601f10610c8157610100808354040283529160200191610cac565b820191906000526020600020905b815481529060010190602001808311610c8f57829003601f168201915b5050505050610eaa565b9050806001600160a01b03168b6001600160a01b031614610cfd576040516316343f1760e31b81526001600160a01b03808d16600483015282166024820152604401610744565b610d84610d3f8a8a8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e8e92505050565b610d7e89898080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e8e92505050565b9061102e565b610da95786868a8a60405163998f70a160e01b81526004016107449493929190612af4565b848460048989604051610dbd929190612947565b90815260200160405180910390209182610dd8929190612a35565b507f87526cc0385862de920bf8b05560b5c9eb58f8af45be9f917801198166655f8887878787604051610ac09493929190612af4565b610e16611041565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b610e418261108a565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115610e865761078882826110ef565b61020c611165565b6000610e9982611184565b92915050565b6060610e9982611198565b60408051808201909152606080825260208201526000610ec983610e8e565b90506000610eef604051806040016040528060018152602001601d60f91b815250610e8e565b9050600080610efe84846114be565b955092509050801580610f3c5750610f3a610f3360405180604001604052806003815260200162191a5960ea1b815250610e8e565b839061150c565b155b15610f5c5785604051631859e3bb60e11b8152600401610744919061261f565b610f6684846114be565b95509250905080610f8c5785604051631859e3bb60e11b8152600401610744919061261f565b6040805180820190915260608082526020820152610fa983611518565b81526040805180820190915260018152601d60f91b6020820152610fd790610fd090610e8e565b8690611523565b9450610fe69150849050611518565b60208201529695505050505050565b60006016611001835190565b0361100e57506000919050565b60006110198361154d565b905061102481612b26565b60601c9392505050565b600061103a838361173f565b9392505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661065e57604051631afcd79f60e31b815260040160405180910390fd5b806001600160a01b03163b6000036110c057604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610744565b600080516020612c4f83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161110c9190612b59565b600060405180830381855af49150503d8060008114611147576040519150601f19603f3d011682016040523d82523d6000602084013e61114c565b606091505b509150915061115c858383611757565b95945050505050565b341561065e5760405163b398979f60e01b815260040160405180910390fd5b60008060208301905061103a8184516117b3565b80516060906031906000805b82811080156111cb5750838682815181106111c1576111c1612b75565b016020015160f81c145b156111dc57600191820191016111a4565b5060008080806117e361209f8702046001016002026001600160401b038111156112085761120861229b565b6040519080825280601f01601f191660200182016040528015611232576020820181803683370190505b5090506000600460038801046001600160401b038111156112555761125561229b565b60405190808252806020026020018201604052801561127e578160200160208202803683370190505b50905060005b8a5181101561137c5760008b82815181106112a1576112a1612b75565b602001015160f81c60f81b90506112d06040518060600160405280603a8152602001612c8f603a9139826117bf565b9096509450846112f5578b604051634cb9e47360e11b8152600401610744919061261f565b8251600019015b60008112611372578684828151811061131757611317612b75565b602002602001015163ffffffff16603a026001600160401b0316019750602088901c96508763ffffffff1684828151811061135457611354612b75565b63ffffffff90921660209283029190910190910152600019016112fc565b5050600101611284565b50600860038816026001600160401b038116600003611399575060205b600719016000805b8351811015611443575b6020836001600160401b0316101561143757826001600160401b03168482815181106113d9576113d9612b75565b602002602001015163ffffffff16901c60f81b8583815181106113fe576113fe612b75565b60200101906001600160f81b031916908160001a90535060019091019060086001600160401b03841610611437576008830392506113ab565b601892506001016113a1565b50875b84518110156114a157600060f81b85828151811061146657611466612b75565b01602001516001600160f81b031916111561149957611488858a830384611822565b9d9c50505050505050505050505050565b600101611446565b506114ae84600083611822565b9c9b505050505050505050505050565b60008080806114cd86866118d3565b905060001981036114e957600086600093509350935050611505565b6114fd86826001600160801b0388166119de565b935093509350505b9250925092565b600061103a8383611a4b565b6060610e9982611a95565b60008080806115328686611b0c565b905060001981036114e9576000808793509350935050611505565b6060600061155a83610e8e565b9050600061158160405180604001604052806002815260200161060f60f31b815250610e8e565b90506115b06115a960405180604001604052806002815260200161060f60f31b815250610e8e565b8390611bfe565b6115cb57505060408051602081019091526000815292915050565b6115dd6115d88383611c0a565b611518565b935060008490506000600282516115f49190612ba1565b6001600160401b0381111561160b5761160b61229b565b6040519080825280601f01601f191660200182016040528015611635576020820181803683370190505b50905060005b81518110156117355760008061167a85611656856002612bc3565b8151811061166657611666612b75565b01602001516001600160f81b031916611c16565b915091508061169f575050604080516020810190915260008152979650505050505050565b6000806116bc876116b1876002612bc3565b611656906001612bda565b91509150806116e35750506040805160208101909152600081529998505050505050505050565b816116ef856010612bed565b6116f99190612c09565b60f81b86868151811061170e5761170e612b75565b60200101906001600160f81b031916908160001a905350506001909301925061163b915050565b5095945050505050565b600060001961174e84846118d3565b14159392505050565b60608261176c5761176782611cfc565b61103a565b815115801561178357506001600160a01b0384163b155b156117ac57604051639996b31560e01b81526001600160a01b0385166004820152602401610744565b5092915050565b600061103a8383611d25565b60008060005b845181101561181257836001600160f81b0319168582815181106117eb576117eb612b75565b01602001516001600160f81b0319160361180a5791506001905061181b565b6001016117c5565b50600080915091505b9250929050565b606060008383036001600160401b038111156118405761184061229b565b6040519080825280601f01601f19166020018201604052801561186a576020820181803683370190505b50905060005b8484038110156118ca57858582018151811061188e5761188e612b75565b602001015160f81c60f81b8282815181106118ab576118ab612b75565b60200101906001600160f81b031916908160001a905350600101611870565b50949350505050565b60006001600160801b038381169083168083036118f557600092505050610e99565b81158061190157508181115b156119125760001992505050610e99565b600061191e8660801c90565b9050600061192c8660801c90565b9050600061193b825160001a90565b90505b600061194b848784611d31565b90506000198103611966576000199650505050505050610e99565b94859003949283019285851115611987576000199650505050505050610e99565b848320858520036119b35761199c8960801c90565b6119a69085612c22565b9650505050505050610e99565b856001036119cb576000199650505050505050610e99565b600019909501946001909301925061193e565b6000806000806119ee8760801c90565b90506001600160801b03871685870181811115611a1e576040516365f4e9df60e01b815260040160405180910390fd5b6001996001600160801b03988916608085811b919091179a50928290039098169201901b17949350505050565b60006001600160801b038381169083168114611a6b576000915050610e99565b611a8d611a788560801c90565b611a828560801c90565b839081902091201490565b949350505050565b60606001600160801b0382166001600160401b03811115611ab857611ab861229b565b6040519080825280601f01601f191660200182016040528015611ae2576020820181803683370190505b50905060208101611b0681611af78560801c90565b6001600160801b038616611df8565b50919050565b60006001600160801b03838116908316808303611b2e57600092505050610e99565b811580611b3a57508181115b15611b4b5760001992505050610e99565b6000611b578660801c90565b90506000611b658660801c90565b90506000611b7287611e06565b905060001984015b6000611b87858885611e4b565b90506000198103611ba357600019975050505050505050610e99565b80821115611bbc57600019975050505050505050610e99565b858420828203868101889020909103611bde579750610e999650505050505050565b8115611bec57509550611b7a565b60001998505050505050505050610e99565b600061103a8383611eff565b600061103a8383611f4c565b600080600360fc1b6001600160f81b0319841610801590611c455750603960f81b6001600160f81b0319841611155b15611c6357611c59603060f885901c612c35565b9360019350915050565b604160f81b6001600160f81b0319841610801590611c8f5750602360f91b6001600160f81b0319841611155b15611caf576041611ca560f885901c600a612c09565b611c599190612c35565b606160f81b6001600160f81b0319841610801590611cdb5750603360f91b6001600160f81b0319841611155b15611cf1576061611ca560f885901c600a612c09565b506000928392509050565b805115611d0c5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b600061103a8383611fa6565b600060208311611d4d57611d4684848461200c565b905061103a565b83601f8416808503820160ff8516600080516020612c6f833981519152025b81881015611dae5787518118611d818161211d565b15611da257848903611d958a60208a61200c565b019550505050505061103a565b60208901985050611d6c565b82600003611dc45760001994505050505061103a565b611dcf82848861200c565b94506000198503611de85760001994505050505061103a565b838203850194505050505061103a565b8083828460045afa50505050565b60006001600160801b038216808203611e32576040516365f4e9df60e01b815260040160405180910390fd5b61103a60018203611e438560801c90565b015160001a90565b600060208311611e6057611d46848484612168565b601f83168484018115611e98578190036000611e7d828487612168565b90506000198114611e96579086900301915061103a9050565b505b60ff8416600080516020612c6f833981519152025b86821115611ef157601f1990910180519091908118611ecb8161211d565b15611eeb57878303611edf84602089612168565b0194505050505061103a565b50611ead565b506000199695505050505050565b60006001600160801b0383811690831680821015611f2257600092505050610e99565b8481831115611f3857611f3586836121b1565b90505b611f428186611a4b565b9695505050505050565b60006001600160801b0383811690831681811115611f6e578492505050610e99565b600080611f7b87846121fc565b9092509050611f8a8287611a4b565b15611f9a579350610e9992505050565b86945050505050610e99565b60006001600160801b03831115611fd05760405163fee7506f60e01b815260040160405180910390fd5b6001600160801b03821115611ff857604051633b6b098d60e01b815260040160405180910390fd5b506001600160801b031660809190911b1790565b825160009081602085111561202057602094505b601285106120aa5760ff8416600080516020612c6f8339815191520282186120506001600160801b03821761211d565b6000036120865760109150601a8610612081576120756001600160401b03821761211d565b60000361208157601891505b6120a4565b6120986001600160c01b03821761211d565b6000036120a457600891505b506120e8565b600a85106120e85760ff8416600080516020612c6f8339815191520282186120da6001600160c01b03821761211d565b6000036120e657600891505b505b848110156121105781811a60ff851681036121075750915061103a9050565b506001016120e8565b5060001995945050505050565b7ffefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefeff81019019167f80808080808080808080808080808080808080808080808080808080808080801690565b6000602083111561217857602092505b83515b83156121a5576000199093019280841a60ff8416810361219f57849250505061103a565b5061217b565b50600019949350505050565b60006001600160801b038316808311156121de576040516365f4e9df60e01b815260040160405180910390fd5b611a8d6121eb8560801c90565b60801b6001600160801b0385161790565b600080600061220b8560801c90565b90506001600160801b03851680851115612238576040516365f4e9df60e01b815260040160405180910390fd5b608082901b6001600160801b038616176122726122558785612bda565b61225f8885612c22565b6001600160801b031660809190911b1790565b9350935050509250929050565b80356001600160a01b038116811461229657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b03808411156122cb576122cb61229b565b604051601f8501601f19908116603f011681019082821181831017156122f3576122f361229b565b8160405280935085815286868601111561230c57600080fd5b858560208301376000602087830101525050509392505050565b6000806040838503121561233957600080fd5b6123428361227f565b915060208301356001600160401b0381111561235d57600080fd5b8301601f8101851361236e57600080fd5b61237d858235602084016122b1565b9150509250929050565b803560ff8116811461229657600080fd5b60008083601f8401126123aa57600080fd5b5081356001600160401b038111156123c157600080fd5b60208301915083602082850101111561181b57600080fd5b60008060008060008060008060008060006101008c8e0312156123fb57600080fd5b6124048c61227f565b9a5061241260208d01612387565b995060408c0135985060608c013597506001600160401b038060808e0135111561243b57600080fd5b61244b8e60808f01358f01612398565b909850965060a08d013581101561246157600080fd5b6124718e60a08f01358f01612398565b909650945060c08d0135935060e08d013581101561248e57600080fd5b5061249f8d60e08e01358e01612398565b81935080925050509295989b509295989b9093969950565b60008060008060008060008060008060e08b8d0312156124d657600080fd5b6124df8b61227f565b99506124ed60208c01612387565b985060408b0135975060608b0135965060808b01356001600160401b038082111561251757600080fd5b6125238e838f01612398565b909850965060a08d013591508082111561253c57600080fd5b6125488e838f01612398565b909650945060c08d013591508082111561256157600080fd5b5061256e8d828e01612398565b915080935050809150509295989b9194979a5092959850565b60006020828403121561259957600080fd5b81356001600160401b038111156125af57600080fd5b8201601f810184136125c057600080fd5b611a8d848235602084016122b1565b60005b838110156125ea5781810151838201526020016125d2565b50506000910152565b6000815180845261260b8160208601602086016125cf565b601f01601f19169290920160200192915050565b60208152600061103a60208301846125f3565b60008060008060008060008060a0898b03121561264e57600080fd5b6126578961227f565b975060208901356001600160401b038082111561267357600080fd5b61267f8c838d01612398565b909950975060408b013591508082111561269857600080fd5b6126a48c838d01612398565b909750955060608b0135945060808b01359150808211156126c457600080fd5b506126d18b828c01612398565b999c989b5096995094979396929594505050565b6000806000606084860312156126fa57600080fd5b6127038461227f565b92506127116020850161227f565b915061271f6040850161227f565b90509250925092565b60008060008060008060006080888a03121561274357600080fd5b61274c8861227f565b965060208801356001600160401b038082111561276857600080fd5b6127748b838c01612398565b909850965060408a013591508082111561278d57600080fd5b6127998b838c01612398565b909650945060608a01359150808211156127b257600080fd5b506127bf8a828b01612398565b989b979a50959850939692959293505050565b6001600160f81b03198c811682528b1660018201526001600160601b031960608b811b821660028401528a901b1660168201526f6372656174654469644d617070696e6760801b602a82015260008789603a840137878201603a8101600081528789823750868101905085603a8201528385605a83013760009301605a0192835250909b9a5050505050505050505050565b6001600160f81b03198b811682528a1660018201526001600160601b031960608a811b8216600284015289901b166016820152746372656174655265736f757263654d617070696e6760581b602a82015260008688603f840137868201603f81016000815286888237508581019050603f810160008152848682375060009301603f0192835250909a9950505050505050505050565b600181811c9082168061290e57607f821691505b602082108103611b0657634e487b7160e01b600052602260045260246000fd5b60006020828403121561294057600080fd5b5051919050565b8183823760009101908152919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b602081526000611a8d602083018486612957565b805160208201516001600160801b031980821692919060108310156129c35780818460100360031b1b83161693505b505050919050565b83815260406020820152600061115c604083018486612957565b601f821115610788576000816000526020600020601f850160051c81016020861015612a0e5750805b601f850160051c820191505b81811015612a2d57828155600101612a1a565b505050505050565b6001600160401b03831115612a4c57612a4c61229b565b612a6083612a5a83546128fa565b836129e5565b6000601f841160018114612a945760008515612a7c5750838201355b600019600387901b1c1916600186901b1783556106bf565b600083815260209020601f19861690835b82811015612ac55786850135825560209485019460019092019101612aa5565b5086821015612ae25760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b604081526000612b08604083018688612957565b8281036020840152612b1b818587612957565b979650505050505050565b805160208201516001600160601b031980821692919060148310156129c35760149290920360031b82901b161692915050565b60008251612b6b8184602087016125cf565b9190910192915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082612bbe57634e487b7160e01b600052601260045260246000fd5b500490565b8082028115828204841417610e9957610e99612b8b565b80820180821115610e9957610e99612b8b565b60ff81811683821602908116908181146117ac576117ac612b8b565b60ff8181168382160190811115610e9957610e99612b8b565b81810381811115610e9957610e99612b8b565b60ff8281168282160390811115610e9957610e99612b8b56fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc010101010101010101010101010101010101010101010101010101010101010131323334353637383941424344454647484a4b4c4d4e505152535455565758595a6162636465666768696a6b6d6e6f707172737475767778797aa2646970667358221220e0b0a714b99821bba1e735cf2e20df77e61b4386b92ed0ea676e426b33fbe2be64736f6c63430008170033" + "code": "0x6080604052600436106100915760003560e01c80639a3265d9116100595780639a3265d914610140578063ad3cb1cc14610160578063c0c53b8b14610191578063c612ab58146101b1578063d924aedb146101d157600080fd5b80634f1ef2861461009657806352d1902d146100ab57806353aac465146100d35780637223460a146100f357806393a8c74214610113575b600080fd5b6100a96100a4366004612326565b6101f1565b005b3480156100b757600080fd5b506100c0610210565b6040519081526020015b60405180910390f35b3480156100df57600080fd5b506100a96100ee3660046123d9565b61022d565b3480156100ff57600080fd5b506100a961010e3660046124b7565b6102ee565b34801561011f57600080fd5b5061013361012e366004612587565b6103a8565b6040516100ca919061261f565b34801561014c57600080fd5b506100a961015b366004612632565b61044d565b34801561016c57600080fd5b50610133604051806040016040528060058152602001640352e302e360dc1b81525081565b34801561019d57600080fd5b506100a96101ac3660046126e5565b610468565b3480156101bd57600080fd5b506101336101cc366004612587565b61057c565b3480156101dd57600080fd5b506100a96101ec366004612728565b6105a0565b6101f96105b9565b61020282610660565b61020c82826106c6565b5050565b600061021a61078d565b50600080516020612c4f83398151915290565b6000601960f81b600060f81b308e8b8b8b8b8b8b8b60405160200161025c9b9a999897969594939291906127d2565b60408051601f1981840301815282825280516020918201206000845290830180835281905260ff8e1691830191909152606082018c9052608082018b905291506102e0908d9060019060a0016020604051602081039080840390855afa1580156102ca573d6000803e3d6000fd5b505050602060405103518a8a8a8a8a8a8a6107d6565b505050505050505050505050565b60405160009061031890601960f81b90839030908f908c908c908c908c908c908c90602001612864565b60408051601f1981840301815282825280516020918201206000845290830180835281905260ff8d1691830191909152606082018b9052608082018a9052915061039b908c9060019060a0016020604051602081039080840390855afa158015610386573d6000803e3d6000fd5b50505060206040510351898989898989610ad5565b5050505050505050505050565b8051602081830181018051600382529282019190930120915280546103cc906128fa565b80601f01602080910402602001604051908101604052809291908181526020018280546103f8906128fa565b80156104455780601f1061041a57610100808354040283529160200191610445565b820191906000526020600020905b81548152906001019060200180831161042857829003601f168201915b505050505081565b61045e8833898989898989896107d6565b5050505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805460019190600160401b900460ff16806104b1575080546001600160401b03808416911610155b156104cf5760405163f92ee8a960e01b815260040160405180910390fd5b805468ffffffffffffffffff19166001600160401b03831617600160401b1781556104f985610e0e565b600180546001600160a01b038681166001600160a01b0319928316179092556002805492861692909116919091179055805468ff0000000000000000191681556040516001600160401b03831681527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050505050565b8051602081830181018051600482529282019190930120915280546103cc906128fa565b6105b08733888888888888610ad5565b50505050505050565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148061064057507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610634600080516020612c4f833981519152546001600160a01b031690565b6001600160a01b031614155b1561065e5760405163703e46dd60e11b815260040160405180910390fd5b565b60005460405163574a81d760e01b81523060048201526001600160a01b0383811660248301529091169063574a81d79060440160006040518083038186803b1580156106ab57600080fd5b505afa1580156106bf573d6000803e3d6000fd5b5050505050565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015610720575060408051601f3d908101601f1916820190925261071d9181019061292e565b60015b61074d57604051634c9c8ce360e01b81526001600160a01b03831660048201526024015b60405180910390fd5b600080516020612c4f833981519152811461077e57604051632a87526960e21b815260048101829052602401610744565b6107888383610e38565b505050565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461065e5760405163703e46dd60e11b815260040160405180910390fd5b8888806001600160a01b0316826001600160a01b03161461081d576040516316343f1760e31b81526001600160a01b03808316600483015283166024820152604401610744565b6002546040516301daf29b60e21b81523360048201526001600160a01b039091169063076bca6c9060240160006040518083038186803b15801561086057600080fd5b505afa158015610874573d6000803e3d6000fd5b5050505061093961092c60038b8b604051610890929190612947565b908152602001604051809103902080546108a9906128fa565b80601f01602080910402602001604051908101604052809291908181526020018280546108d5906128fa565b80156109225780601f106108f757610100808354040283529160200191610922565b820191906000526020600020905b81548152906001019060200180831161090557829003601f168201915b5050505050610e8e565b6001600160801b03161590565b61095a578888604051630ab7bdc760e21b8152600401610744929190612980565b846001600160801b0319166109a48a8a8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e9f92505050565b6109ad90612994565b6001600160801b031916146109db57848989604051630876c99d60e21b8152600401610744939291906129cb565b610a26610a1d88888080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610eaa92505050565b60200151610ff5565b6001600160a01b03168b6001600160a01b031614610a5b578686604051631859e3bb60e11b8152600401610744929190612980565b868660038b8b604051610a6f929190612947565b90815260200160405180910390209182610a8a929190612a35565b507ff214be33ffacf63cd5f2d1636bef433e47c400b94d565c786049bfa836c20e1989898989604051610ac09493929190612af4565b60405180910390a15050505050505050505050565b8787806001600160a01b0316826001600160a01b031614610b1c576040516316343f1760e31b81526001600160a01b03808316600483015283166024820152604401610744565b6002546040516301daf29b60e21b81523360048201526001600160a01b039091169063076bca6c9060240160006040518083038186803b158015610b5f57600080fd5b505afa158015610b73573d6000803e3d6000fd5b5050505060048686604051610b89929190612947565b90815260200160405180910390208054610ba2906128fa565b159050610bc65785856040516327ef3c3d60e01b8152600401610744929190612980565b610bde61092c60038a8a604051610890929190612947565b15610c0057858560405163a54e9cfb60e01b8152600401610744929190612980565b6000610cb6610a1d60038b8b604051610c1a929190612947565b90815260200160405180910390208054610c33906128fa565b80601f0160208091040260200160405190810160405280929190818152602001828054610c5f906128fa565b8015610cac5780601f10610c8157610100808354040283529160200191610cac565b820191906000526020600020905b815481529060010190602001808311610c8f57829003601f168201915b5050505050610eaa565b9050806001600160a01b03168b6001600160a01b031614610cfd576040516316343f1760e31b81526001600160a01b03808d16600483015282166024820152604401610744565b610d84610d3f8a8a8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e8e92505050565b610d7e89898080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e8e92505050565b9061102e565b610da95786868a8a60405163998f70a160e01b81526004016107449493929190612af4565b848460048989604051610dbd929190612947565b90815260200160405180910390209182610dd8929190612a35565b507f87526cc0385862de920bf8b05560b5c9eb58f8af45be9f917801198166655f8887878787604051610ac09493929190612af4565b610e16611041565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b610e418261108a565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115610e865761078882826110ef565b61020c611165565b6000610e9982611184565b92915050565b6060610e9982611198565b60408051808201909152606080825260208201526000610ec983610e8e565b90506000610eef604051806040016040528060018152602001601d60f91b815250610e8e565b9050600080610efe84846114be565b955092509050801580610f3c5750610f3a610f3360405180604001604052806003815260200162191a5960ea1b815250610e8e565b839061150c565b155b15610f5c5785604051631859e3bb60e11b8152600401610744919061261f565b610f6684846114be565b95509250905080610f8c5785604051631859e3bb60e11b8152600401610744919061261f565b6040805180820190915260608082526020820152610fa983611518565b81526040805180820190915260018152601d60f91b6020820152610fd790610fd090610e8e565b8690611523565b9450610fe69150849050611518565b60208201529695505050505050565b60006016611001835190565b0361100e57506000919050565b60006110198361154d565b905061102481612b26565b60601c9392505050565b600061103a838361173f565b9392505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661065e57604051631afcd79f60e31b815260040160405180910390fd5b806001600160a01b03163b6000036110c057604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610744565b600080516020612c4f83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161110c9190612b59565b600060405180830381855af49150503d8060008114611147576040519150601f19603f3d011682016040523d82523d6000602084013e61114c565b606091505b509150915061115c858383611757565b95945050505050565b341561065e5760405163b398979f60e01b815260040160405180910390fd5b60008060208301905061103a8184516117b3565b80516060906031906000805b82811080156111cb5750838682815181106111c1576111c1612b75565b016020015160f81c145b156111dc57600191820191016111a4565b5060008080806117e361209f8702046001016002026001600160401b038111156112085761120861229b565b6040519080825280601f01601f191660200182016040528015611232576020820181803683370190505b5090506000600460038801046001600160401b038111156112555761125561229b565b60405190808252806020026020018201604052801561127e578160200160208202803683370190505b50905060005b8a5181101561137c5760008b82815181106112a1576112a1612b75565b602001015160f81c60f81b90506112d06040518060600160405280603a8152602001612c8f603a9139826117bf565b9096509450846112f5578b604051634cb9e47360e11b8152600401610744919061261f565b8251600019015b60008112611372578684828151811061131757611317612b75565b602002602001015163ffffffff16603a026001600160401b0316019750602088901c96508763ffffffff1684828151811061135457611354612b75565b63ffffffff90921660209283029190910190910152600019016112fc565b5050600101611284565b50600860038816026001600160401b038116600003611399575060205b600719016000805b8351811015611443575b6020836001600160401b0316101561143757826001600160401b03168482815181106113d9576113d9612b75565b602002602001015163ffffffff16901c60f81b8583815181106113fe576113fe612b75565b60200101906001600160f81b031916908160001a90535060019091019060086001600160401b03841610611437576008830392506113ab565b601892506001016113a1565b50875b84518110156114a157600060f81b85828151811061146657611466612b75565b01602001516001600160f81b031916111561149957611488858a830384611822565b9d9c50505050505050505050505050565b600101611446565b506114ae84600083611822565b9c9b505050505050505050505050565b60008080806114cd86866118d3565b905060001981036114e957600086600093509350935050611505565b6114fd86826001600160801b0388166119de565b935093509350505b9250925092565b600061103a8383611a4b565b6060610e9982611a95565b60008080806115328686611b0c565b905060001981036114e9576000808793509350935050611505565b6060600061155a83610e8e565b9050600061158160405180604001604052806002815260200161060f60f31b815250610e8e565b90506115b06115a960405180604001604052806002815260200161060f60f31b815250610e8e565b8390611bfe565b6115cb57505060408051602081019091526000815292915050565b6115dd6115d88383611c0a565b611518565b935060008490506000600282516115f49190612ba1565b6001600160401b0381111561160b5761160b61229b565b6040519080825280601f01601f191660200182016040528015611635576020820181803683370190505b50905060005b81518110156117355760008061167a85611656856002612bc3565b8151811061166657611666612b75565b01602001516001600160f81b031916611c16565b915091508061169f575050604080516020810190915260008152979650505050505050565b6000806116bc876116b1876002612bc3565b611656906001612bda565b91509150806116e35750506040805160208101909152600081529998505050505050505050565b816116ef856010612bed565b6116f99190612c09565b60f81b86868151811061170e5761170e612b75565b60200101906001600160f81b031916908160001a905350506001909301925061163b915050565b5095945050505050565b600060001961174e84846118d3565b14159392505050565b60608261176c5761176782611cfc565b61103a565b815115801561178357506001600160a01b0384163b155b156117ac57604051639996b31560e01b81526001600160a01b0385166004820152602401610744565b5092915050565b600061103a8383611d25565b60008060005b845181101561181257836001600160f81b0319168582815181106117eb576117eb612b75565b01602001516001600160f81b0319160361180a5791506001905061181b565b6001016117c5565b50600080915091505b9250929050565b606060008383036001600160401b038111156118405761184061229b565b6040519080825280601f01601f19166020018201604052801561186a576020820181803683370190505b50905060005b8484038110156118ca57858582018151811061188e5761188e612b75565b602001015160f81c60f81b8282815181106118ab576118ab612b75565b60200101906001600160f81b031916908160001a905350600101611870565b50949350505050565b60006001600160801b038381169083168083036118f557600092505050610e99565b81158061190157508181115b156119125760001992505050610e99565b600061191e8660801c90565b9050600061192c8660801c90565b9050600061193b825160001a90565b90505b600061194b848784611d31565b90506000198103611966576000199650505050505050610e99565b94859003949283019285851115611987576000199650505050505050610e99565b848320858520036119b35761199c8960801c90565b6119a69085612c22565b9650505050505050610e99565b856001036119cb576000199650505050505050610e99565b600019909501946001909301925061193e565b6000806000806119ee8760801c90565b90506001600160801b03871685870181811115611a1e576040516365f4e9df60e01b815260040160405180910390fd5b6001996001600160801b03988916608085811b919091179a50928290039098169201901b17949350505050565b60006001600160801b038381169083168114611a6b576000915050610e99565b611a8d611a788560801c90565b611a828560801c90565b839081902091201490565b949350505050565b60606001600160801b0382166001600160401b03811115611ab857611ab861229b565b6040519080825280601f01601f191660200182016040528015611ae2576020820181803683370190505b50905060208101611b0681611af78560801c90565b6001600160801b038616611df8565b50919050565b60006001600160801b03838116908316808303611b2e57600092505050610e99565b811580611b3a57508181115b15611b4b5760001992505050610e99565b6000611b578660801c90565b90506000611b658660801c90565b90506000611b7287611e06565b905060001984015b6000611b87858885611e4b565b90506000198103611ba357600019975050505050505050610e99565b80821115611bbc57600019975050505050505050610e99565b858420828203868101889020909103611bde579750610e999650505050505050565b8115611bec57509550611b7a565b60001998505050505050505050610e99565b600061103a8383611eff565b600061103a8383611f4c565b600080600360fc1b6001600160f81b0319841610801590611c455750603960f81b6001600160f81b0319841611155b15611c6357611c59603060f885901c612c35565b9360019350915050565b604160f81b6001600160f81b0319841610801590611c8f5750602360f91b6001600160f81b0319841611155b15611caf576041611ca560f885901c600a612c09565b611c599190612c35565b606160f81b6001600160f81b0319841610801590611cdb5750603360f91b6001600160f81b0319841611155b15611cf1576061611ca560f885901c600a612c09565b506000928392509050565b805115611d0c5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b600061103a8383611fa6565b600060208311611d4d57611d4684848461200c565b905061103a565b83601f8416808503820160ff8516600080516020612c6f833981519152025b81881015611dae5787518118611d818161211d565b15611da257848903611d958a60208a61200c565b019550505050505061103a565b60208901985050611d6c565b82600003611dc45760001994505050505061103a565b611dcf82848861200c565b94506000198503611de85760001994505050505061103a565b838203850194505050505061103a565b8083828460045afa50505050565b60006001600160801b038216808203611e32576040516365f4e9df60e01b815260040160405180910390fd5b61103a60018203611e438560801c90565b015160001a90565b600060208311611e6057611d46848484612168565b601f83168484018115611e98578190036000611e7d828487612168565b90506000198114611e96579086900301915061103a9050565b505b60ff8416600080516020612c6f833981519152025b86821115611ef157601f1990910180519091908118611ecb8161211d565b15611eeb57878303611edf84602089612168565b0194505050505061103a565b50611ead565b506000199695505050505050565b60006001600160801b0383811690831680821015611f2257600092505050610e99565b8481831115611f3857611f3586836121b1565b90505b611f428186611a4b565b9695505050505050565b60006001600160801b0383811690831681811115611f6e578492505050610e99565b600080611f7b87846121fc565b9092509050611f8a8287611a4b565b15611f9a579350610e9992505050565b86945050505050610e99565b60006001600160801b03831115611fd05760405163fee7506f60e01b815260040160405180910390fd5b6001600160801b03821115611ff857604051633b6b098d60e01b815260040160405180910390fd5b506001600160801b031660809190911b1790565b825160009081602085111561202057602094505b601285106120aa5760ff8416600080516020612c6f8339815191520282186120506001600160801b03821761211d565b6000036120865760109150601a8610612081576120756001600160401b03821761211d565b60000361208157601891505b6120a4565b6120986001600160c01b03821761211d565b6000036120a457600891505b506120e8565b600a85106120e85760ff8416600080516020612c6f8339815191520282186120da6001600160c01b03821761211d565b6000036120e657600891505b505b848110156121105781811a60ff851681036121075750915061103a9050565b506001016120e8565b5060001995945050505050565b7ffefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefeff81019019167f80808080808080808080808080808080808080808080808080808080808080801690565b6000602083111561217857602092505b83515b83156121a5576000199093019280841a60ff8416810361219f57849250505061103a565b5061217b565b50600019949350505050565b60006001600160801b038316808311156121de576040516365f4e9df60e01b815260040160405180910390fd5b611a8d6121eb8560801c90565b60801b6001600160801b0385161790565b600080600061220b8560801c90565b90506001600160801b03851680851115612238576040516365f4e9df60e01b815260040160405180910390fd5b608082901b6001600160801b038616176122726122558785612bda565b61225f8885612c22565b6001600160801b031660809190911b1790565b9350935050509250929050565b80356001600160a01b038116811461229657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b03808411156122cb576122cb61229b565b604051601f8501601f19908116603f011681019082821181831017156122f3576122f361229b565b8160405280935085815286868601111561230c57600080fd5b858560208301376000602087830101525050509392505050565b6000806040838503121561233957600080fd5b6123428361227f565b915060208301356001600160401b0381111561235d57600080fd5b8301601f8101851361236e57600080fd5b61237d858235602084016122b1565b9150509250929050565b803560ff8116811461229657600080fd5b60008083601f8401126123aa57600080fd5b5081356001600160401b038111156123c157600080fd5b60208301915083602082850101111561181b57600080fd5b60008060008060008060008060008060006101008c8e0312156123fb57600080fd5b6124048c61227f565b9a5061241260208d01612387565b995060408c0135985060608c013597506001600160401b038060808e0135111561243b57600080fd5b61244b8e60808f01358f01612398565b909850965060a08d013581101561246157600080fd5b6124718e60a08f01358f01612398565b909650945060c08d0135935060e08d013581101561248e57600080fd5b5061249f8d60e08e01358e01612398565b81935080925050509295989b509295989b9093969950565b60008060008060008060008060008060e08b8d0312156124d657600080fd5b6124df8b61227f565b99506124ed60208c01612387565b985060408b0135975060608b0135965060808b01356001600160401b038082111561251757600080fd5b6125238e838f01612398565b909850965060a08d013591508082111561253c57600080fd5b6125488e838f01612398565b909650945060c08d013591508082111561256157600080fd5b5061256e8d828e01612398565b915080935050809150509295989b9194979a5092959850565b60006020828403121561259957600080fd5b81356001600160401b038111156125af57600080fd5b8201601f810184136125c057600080fd5b611a8d848235602084016122b1565b60005b838110156125ea5781810151838201526020016125d2565b50506000910152565b6000815180845261260b8160208601602086016125cf565b601f01601f19169290920160200192915050565b60208152600061103a60208301846125f3565b60008060008060008060008060a0898b03121561264e57600080fd5b6126578961227f565b975060208901356001600160401b038082111561267357600080fd5b61267f8c838d01612398565b909950975060408b013591508082111561269857600080fd5b6126a48c838d01612398565b909750955060608b0135945060808b01359150808211156126c457600080fd5b506126d18b828c01612398565b999c989b5096995094979396929594505050565b6000806000606084860312156126fa57600080fd5b6127038461227f565b92506127116020850161227f565b915061271f6040850161227f565b90509250925092565b60008060008060008060006080888a03121561274357600080fd5b61274c8861227f565b965060208801356001600160401b038082111561276857600080fd5b6127748b838c01612398565b909850965060408a013591508082111561278d57600080fd5b6127998b838c01612398565b909650945060608a01359150808211156127b257600080fd5b506127bf8a828b01612398565b989b979a50959850939692959293505050565b6001600160f81b03198c811682528b1660018201526001600160601b031960608b811b821660028401528a901b1660168201526f6372656174654469644d617070696e6760801b602a82015260008789603a840137878201603a8101600081528789823750868101905085603a8201528385605a83013760009301605a0192835250909b9a5050505050505050505050565b6001600160f81b03198b811682528a1660018201526001600160601b031960608a811b8216600284015289901b166016820152746372656174655265736f757263654d617070696e6760581b602a82015260008688603f840137868201603f81016000815286888237508581019050603f810160008152848682375060009301603f0192835250909a9950505050505050505050565b600181811c9082168061290e57607f821691505b602082108103611b0657634e487b7160e01b600052602260045260246000fd5b60006020828403121561294057600080fd5b5051919050565b8183823760009101908152919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b602081526000611a8d602083018486612957565b805160208201516001600160801b031980821692919060108310156129c35780818460100360031b1b83161693505b505050919050565b83815260406020820152600061115c604083018486612957565b601f821115610788576000816000526020600020601f850160051c81016020861015612a0e5750805b601f850160051c820191505b81811015612a2d57828155600101612a1a565b505050505050565b6001600160401b03831115612a4c57612a4c61229b565b612a6083612a5a83546128fa565b836129e5565b6000601f841160018114612a945760008515612a7c5750838201355b600019600387901b1c1916600186901b1783556106bf565b600083815260209020601f19861690835b82811015612ac55786850135825560209485019460019092019101612aa5565b5086821015612ae25760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b604081526000612b08604083018688612957565b8281036020840152612b1b818587612957565b979650505050505050565b805160208201516001600160601b031980821692919060148310156129c35760149290920360031b82901b161692915050565b60008251612b6b8184602087016125cf565b9190910192915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082612bbe57634e487b7160e01b600052601260045260246000fd5b500490565b8082028115828204841417610e9957610e99612b8b565b80820180821115610e9957610e99612b8b565b60ff81811683821602908116908181146117ac576117ac612b8b565b60ff8181168382160190811115610e9957610e99612b8b565b81810381811115610e9957610e99612b8b565b60ff8281168282160390811115610e9957610e99612b8b56fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc010101010101010101010101010101010101010101010101010101010101010131323334353637383941424344454647484a4b4c4d4e505152535455565758595a6162636465666768696a6b6d6e6f707172737475767778797aa2646970667358221220d082e1f6555e53a96f9a2a79f9d1524aa10ace94483d7a38bb4ec41bad6454d364736f6c63430008170033" } } } diff --git a/network/config/nodes/validator5/key b/network/config/nodes/validator5/key index 49c2eff5..cd674ebd 100644 --- a/network/config/nodes/validator5/key +++ b/network/config/nodes/validator5/key @@ -1 +1 @@ -0x172c22cdceb87c56ef30c9b4cd34b20c3c63c19cc6bd7b7d12c2dfd2179b3f86 \ No newline at end of file +0x40b6b9dc85d45b8bd1d8edc548ace4e5fd6c705bbf28a509f12791777b6b8843 \ No newline at end of file diff --git a/smart_contracts/contracts/migration/LegacyMappingRegistry.sol b/smart_contracts/contracts/migration/LegacyMappingRegistry.sol index a0a299fb..6a308adf 100644 --- a/smart_contracts/contracts/migration/LegacyMappingRegistry.sol +++ b/smart_contracts/contracts/migration/LegacyMappingRegistry.sol @@ -78,7 +78,7 @@ contract LegacyMappingRegistry is LegacyMappingRegistryInterface, ControlledUpgr string calldata legacyIdentifier, string calldata newDid, bytes32 ed25519Key, - bytes calldata ed25518Signature + bytes calldata ed25519Signature ) public virtual { bytes32 hash = keccak256( abi.encodePacked( @@ -90,7 +90,7 @@ contract LegacyMappingRegistry is LegacyMappingRegistryInterface, ControlledUpgr legacyIdentifier, newDid, ed25519Key, - ed25518Signature + ed25519Signature ) ); _createDidMapping( @@ -99,7 +99,7 @@ contract LegacyMappingRegistry is LegacyMappingRegistryInterface, ControlledUpgr legacyIdentifier, newDid, ed25519Key, - ed25518Signature + ed25519Signature ); } @@ -150,7 +150,7 @@ contract LegacyMappingRegistry is LegacyMappingRegistryInterface, ControlledUpgr string calldata legacyIdentifier, string calldata newDid, bytes32 ed25519Key, - bytes calldata ed25518Signature + bytes calldata ed25519Signature ) internal _identityOwner(identity, actor) _senderIsTrusteeOrEndorserOrSteward { // Checks the uniqueness of the DID mapping if (!isEmpty(didMapping[legacyIdentifier].toSlice())) revert DidMappingAlreadyExist(legacyIdentifier); diff --git a/smart_contracts/test/migration/LegacyMappingRegistry.spec.ts b/smart_contracts/test/migration/LegacyMappingRegistry.spec.ts index 0bdb8ca7..5b58a510 100644 --- a/smart_contracts/test/migration/LegacyMappingRegistry.spec.ts +++ b/smart_contracts/test/migration/LegacyMappingRegistry.spec.ts @@ -63,7 +63,7 @@ describe('LegacyMappingRegistry', function () { ).to.be.revertedWithCustomError(legacyMappingRegistry.baseInstance, MigrationErrors.DidMappingAlreadyExist) }) - it('Should fail if DID mapping is being created with not matching ed25518 key', async function () { + it('Should fail if DID mapping is being created with not matching ed25519 key', async function () { const ed25519Key = Uint8Array.from([ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 25, 180, 23, 224, 175, 15, 188, 235, 170, 233, 240, 145, 111, 204, 153, 108, 117, 188, 145, diff --git a/vdr/src/client/client.rs b/vdr/src/client/client.rs index 0f9bd9c2..60286160 100644 --- a/vdr/src/client/client.rs +++ b/vdr/src/client/client.rs @@ -19,6 +19,7 @@ use crate::{ Address, BlockDetails, QuorumConfig, }; +/// Client object for interaction with the network pub struct LedgerClient { chain_id: u64, client: Box, @@ -31,14 +32,14 @@ impl LedgerClient { /// Create client interacting with ledger /// /// # Params - /// - `chain_id` - chain id of network (chain ID is part of the transaction signing process to protect against transaction replay attack) - /// - `rpc_node` - string - RPC node endpoint - /// - `network` - string - Name of the network - /// - `contract_configs` - [ContractSpec] specifications for contracts deployed on the network - /// - `quorum_config` - Option<[QuorumConfig]> quorum configuration. Can be None if quorum check is not needed + /// - `chain_id`: [u64] - chain id of network (chain ID is part of the transaction signing process to protect against transaction replay attack) + /// - `rpc_node`: [String] - RPC node endpoint + /// - `network`: [String] - Name of the network + /// - `contract_configs`: [ContractSpec] - specifications for contracts deployed on the network + /// - `quorum_config`: Option<[QuorumConfig]> - quorum configuration. Can be None if quorum check is not needed /// /// # Returns - /// client to use for building and sending transactions + /// client: [LedgerClient] - client to use for building and sending transactions #[logfn(Info)] #[logfn_inputs(Debug)] pub fn new( @@ -70,7 +71,7 @@ impl LedgerClient { /// Ping Ledger. /// /// # Returns - /// ping status + /// status: [PingStatus] - ping status #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn ping(&self) -> VdrResult { @@ -84,10 +85,10 @@ impl LedgerClient { /// Depending on the transaction type Write/Read ethereum methods will be used /// /// #Params - /// `transaction` - transaction to submit + /// `transaction`: [Transaction] - transaction to submit /// /// #Returns - /// transaction execution result: + /// response: [Vec] - transaction execution result: /// depending on the type it will be either result bytes or block hash #[logfn(Info)] #[logfn_inputs(Debug)] @@ -111,10 +112,10 @@ impl LedgerClient { /// Submit prepared events query to the ledger /// /// #Params - /// `query` - events query to submit + /// `query`: [EventQuery] - events query to submit /// /// #Returns - /// log events received from the ledger + /// events: [Vec] - list of log events received from the ledger #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn query_events(&self, query: &EventQuery) -> VdrResult> { @@ -126,10 +127,10 @@ impl LedgerClient { /// Get receipt for the given block hash /// /// # Params - /// `transaction` - transaction to submit + /// `transaction`: [Transaction] - transaction to submit /// /// # Returns - /// receipt for the given block + /// receipt: [String] - receipt for the given block #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn get_receipt(&self, hash: &[u8]) -> VdrResult { @@ -139,10 +140,10 @@ impl LedgerClient { /// Get a number of transactions sent by the given account address /// /// # Params - /// `address` - target account address + /// `address`: [Address] - target account address /// /// # Returns - /// number of sent transaction + /// count: [u64] - number of transaction sent by the given account #[logfn(Info)] #[logfn_inputs(Debug)] pub(crate) async fn get_transaction_count(&self, address: &Address) -> VdrResult { diff --git a/vdr/src/client/implementation/web3/client.rs b/vdr/src/client/implementation/web3/client.rs index 88694ba4..02a046db 100644 --- a/vdr/src/client/implementation/web3/client.rs +++ b/vdr/src/client/implementation/web3/client.rs @@ -50,17 +50,13 @@ impl Web3Client { #[logfn(Info)] #[logfn_inputs(Debug)] pub fn new(node_address: &str) -> VdrResult { - trace!("Web3Client::new >>> node_address: {}", node_address); - let transport = Http::new(node_address).map_err(|_| VdrError::ClientNodeUnreachable)?; let web3 = Web3::new(transport); let web3_client = Web3Client { client: web3 }; - - trace!("Web3Client::new <<<"); Ok(web3_client) } - pub fn eth(&self) -> Eth { + pub(crate) fn eth(&self) -> Eth { self.client.eth() } } diff --git a/vdr/src/client/implementation/web3/contract.rs b/vdr/src/client/implementation/web3/contract.rs index 125af635..0aef2411 100644 --- a/vdr/src/client/implementation/web3/contract.rs +++ b/vdr/src/client/implementation/web3/contract.rs @@ -7,7 +7,7 @@ use crate::{ use std::fmt::{Debug, Formatter}; use ethabi::Event; -use log::{trace, warn}; +use log::warn; use log_derive::{logfn, logfn_inputs}; use std::str::FromStr; @@ -30,17 +30,13 @@ pub struct Web3Contract { } impl Web3Contract { + #[logfn(Trace)] + #[logfn_inputs(Trace)] pub fn new( web3_client: &Web3Client, address: &str, contract_spec: &ContractSpec, ) -> VdrResult { - trace!( - "Web3Contract::new >>> address: {:?}, address: {:?}", - address, - contract_spec - ); - let abi = serde_json::to_vec(&contract_spec.abi).map_err(|err| { let vdr_error = VdrError::CommonInvalidData(format!( "Unable to parse contract ABI from specification. Err: {:?}", @@ -64,7 +60,6 @@ impl Web3Contract { let contract = Web3ContractImpl::from_json(web3_client.eth(), parsed_address, abi.as_slice())?; - trace!("Web3Contract::new <<< contract: {:?}", contract); Ok(Web3Contract { contract, address: Address::from(address), diff --git a/vdr/src/client/mod.rs b/vdr/src/client/mod.rs index 405b64bb..027204c0 100644 --- a/vdr/src/client/mod.rs +++ b/vdr/src/client/mod.rs @@ -23,7 +23,7 @@ pub trait Client: Sync + Send + Debug { /// Retrieve count of transaction for the given account /// /// # Params - /// - `address` address of an account to get number of written transactions + /// - `address` [Address] address of an account to get number of written transactions /// /// # Returns /// number of transactions @@ -32,8 +32,7 @@ pub trait Client: Sync + Send + Debug { /// Submit transaction to the ledger /// /// # Params - /// - `transaction` transaction to submit - /// - `transaction` prepared transaction to submit + /// - `transaction` [Transaction] transaction to submit /// /// # Returns /// hash of a block in which transaction included @@ -42,7 +41,7 @@ pub trait Client: Sync + Send + Debug { /// Submit read transaction to the ledger /// /// # Params - /// - `transaction` prepared transaction to submit + /// - `transaction` [Transaction] prepared transaction to submit /// /// # Returns /// result data of transaction execution @@ -51,8 +50,7 @@ pub trait Client: Sync + Send + Debug { /// Send a prepared query for retrieving log events on the ledger /// /// #Params - /// param: client: Ledger - client (Ethereum client - for example web3::Http) - /// param: query: EventQuery - query to send + /// - `query` [EventQuery] query to send /// /// #Returns /// logs - list of received events @@ -92,12 +90,18 @@ pub trait Contract: Sync + Send + Debug { /// Get the contract function /// + /// # Params + /// - `name` name of a contract method + /// /// # Returns /// Contract function fn function(&self, name: &str) -> VdrResult<&Function>; /// Get the contract event /// + /// # Params + /// - `name` name of a contract event + /// /// # Returns /// Contract event fn event(&self, name: &str) -> VdrResult<&Event>; diff --git a/vdr/src/contracts/anoncreds/credential_definition_registry.rs b/vdr/src/contracts/anoncreds/credential_definition_registry.rs index 3fa6b3e5..24b82650 100644 --- a/vdr/src/contracts/anoncreds/credential_definition_registry.rs +++ b/vdr/src/contracts/anoncreds/credential_definition_registry.rs @@ -8,10 +8,10 @@ use crate::{ }, error::VdrResult, types::{ - Address, MethodStringParam, Transaction, TransactionBuilder, - TransactionEndorsingDataBuilder, TransactionParser, TransactionType, + Address, Transaction, TransactionBuilder, TransactionEndorsingDataBuilder, + TransactionParser, TransactionType, }, - SignatureData, TransactionEndorsingData, VdrError, + TransactionEndorsingData, VdrError, }; const CONTRACT_NAME: &str = "CredentialDefinitionRegistry"; @@ -19,16 +19,15 @@ const METHOD_CREATE_CREDENTIAL_DEFINITION: &str = "createCredentialDefinition"; const METHOD_CREATE_CREDENTIAL_DEFINITION_SIGNED: &str = "createCredentialDefinitionSigned"; const METHOD_RESOLVE_CREDENTIAL_DEFINITION: &str = "resolveCredentialDefinition"; -/// Build transaction to execute CredentialDefinitionRegistry.createCredentialDefinition contract -/// method to create a new Credential Definition +/// Build a transaction to create a new Credential Definition record (CredentialDefinitionRegistry.createCredentialDefinition contract method) /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address -/// - `credential_definition` Credential Definition object matching to the specification - https://hyperledger.github.io/anoncreds-spec/#term:credential-definition +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `from`: [Address] - transaction sender account address +/// - `credential_definition`: [CredentialDefinition] - object matching to the specification - `` /// /// # Returns -/// Write transaction to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_create_credential_definition_transaction( @@ -52,14 +51,15 @@ pub async fn build_create_credential_definition_transaction( .await } -/// Prepared data for endorsing CredentialDefinitionRegistry.createCredentialDefinition contract method +/// Prepared data for endorsing creation of a new Credential Definition record +/// (CredentialDefinitionRegistry.createCredentialDefinitionSigned contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `credential_definition` Credential Definition object matching to the specification - https://hyperledger.github.io/anoncreds-spec/#term:credential-definition +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `credential_definition`: [CredentialDefinition] - object matching to the specification - `` /// /// #Returns -/// data: TransactionEndorsingData - transaction endorsement data to sign +/// data: [TransactionEndorsingData] - transaction endorsement data to sign #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_create_credential_definition_endorsing_data( @@ -67,69 +67,28 @@ pub async fn build_create_credential_definition_endorsing_data( credential_definition: &CredentialDefinition, ) -> VdrResult { credential_definition.validate()?; - let identity = Address::try_from(&credential_definition.issuer_id)?; TransactionEndorsingDataBuilder::new() .set_contract(CONTRACT_NAME) - .set_identity(&identity) - .add_param(&identity)? - .add_param(&MethodStringParam::from( - METHOD_CREATE_CREDENTIAL_DEFINITION, - ))? - .add_param(&credential_definition.id().without_network()?)? - .add_param(&credential_definition.issuer_id.without_network()?)? - .add_param(&credential_definition.schema_id.without_network()?)? - .add_param(credential_definition)? - .build(client) - .await -} - -/// Build transaction to execute CredentialDefinitionRegistry.createCredentialDefinitionSigned contract method to -/// endorse a new Credential Definition -/// Endorsing version of the method - sender is not identity owner -/// -/// #Params -/// - `client` client connected to the network where contract will be executed -/// - `credential_definition` Credential Definition object matching to the specification - https://hyperledger.github.io/anoncreds-spec/#term:credential-definition -/// - `signature` signature of schema issuer -/// -/// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit -#[logfn(Info)] -#[logfn_inputs(Debug)] -pub async fn build_create_credential_definition_signed_transaction( - client: &LedgerClient, - from: &Address, - credential_definition: &CredentialDefinition, - signature: &SignatureData, -) -> VdrResult { - credential_definition.validate()?; - let identity = Address::try_from(&credential_definition.issuer_id)?; - TransactionBuilder::new() - .set_contract(CONTRACT_NAME) - .set_method(METHOD_CREATE_CREDENTIAL_DEFINITION_SIGNED) - .add_param(&identity)? - .add_param(&signature.v())? - .add_param(&signature.r())? - .add_param(&signature.s())? + .set_identity(&Address::try_from(&credential_definition.issuer_id)?) + .set_method(METHOD_CREATE_CREDENTIAL_DEFINITION) + .set_endorsing_method(METHOD_CREATE_CREDENTIAL_DEFINITION_SIGNED) .add_param(&credential_definition.id().without_network()?)? .add_param(&credential_definition.issuer_id.without_network()?)? .add_param(&credential_definition.schema_id.without_network()?)? .add_param(credential_definition)? - .set_type(TransactionType::Write) - .set_from(from) .build(client) .await } -/// Build transaction to execute CredentialDefinitionRegistry.resolveCredentialDefinition contract -/// method to retrieve an existing Credential Definition by the given id +/// Build a transaction to resolve an existing Credential Definition record by the given id +/// (CredentialDefinitionRegistry.resolveCredentialDefinition contract method) /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `id` id of Credential Definition to resolve +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `id`: [CredentialDefinitionId] - id of Credential Definition to resolve /// /// # Returns -/// Read transaction to submit +/// transaction: [Transaction] - prepared read transaction object to submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_resolve_credential_definition_transaction( @@ -149,11 +108,11 @@ pub async fn build_resolve_credential_definition_transaction( /// method to receive a Credential Definition associated with the id /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns -/// parsed Credential Definition +/// record: [CredentialDefinitionRecord] - parsed Credential Definition Record #[logfn(Info)] #[logfn_inputs(Debug)] pub fn parse_resolve_credential_definition_result( @@ -169,11 +128,11 @@ pub fn parse_resolve_credential_definition_result( /// Single step function to resolve a Credential Definition for the given ID /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `id` id of credential definition to resolve +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `id`: [CredentialDefinitionId] - id of credential definition to resolve /// /// # Returns -/// Resolved Credential Definition object +/// credential_definition: [CredentialDefinition] - Resolved Credential Definition object pub async fn resolve_credential_definition( client: &LedgerClient, id: &CredentialDefinitionId, @@ -225,7 +184,6 @@ pub mod test { }, }; use rstest::rstest; - use std::sync::RwLock; mod build_create_credential_definition_transaction { use super::*; @@ -239,7 +197,6 @@ pub mod test { &SchemaId::from(SCHEMA_ID), Some(CREDENTIAL_DEFINITION_TAG), ); - println!("cred_def {:?}", cred_def); let transaction = build_create_credential_definition_transaction(&client, &TEST_ACCOUNT, &cred_def) .await @@ -283,7 +240,7 @@ pub mod test { 56, 57, 51, 34, 44, 34, 122, 34, 58, 34, 54, 51, 50, 46, 46, 46, 48, 48, 53, 34, 125, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); @@ -343,7 +300,7 @@ pub mod test { 127, 142, 109, 135, 11, 231, 119, 100, 109, 44, 92, 49, 82, 133, 141, 241, 182, 157, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); diff --git a/vdr/src/contracts/anoncreds/schema_registry.rs b/vdr/src/contracts/anoncreds/schema_registry.rs index a6047e6a..63f0026e 100644 --- a/vdr/src/contracts/anoncreds/schema_registry.rs +++ b/vdr/src/contracts/anoncreds/schema_registry.rs @@ -8,10 +8,10 @@ use crate::{ }, error::VdrResult, types::{ - Address, MethodStringParam, Transaction, TransactionBuilder, - TransactionEndorsingDataBuilder, TransactionParser, TransactionType, + Address, Transaction, TransactionBuilder, TransactionEndorsingDataBuilder, + TransactionParser, TransactionType, }, - SignatureData, TransactionEndorsingData, VdrError, + TransactionEndorsingData, VdrError, }; const CONTRACT_NAME: &str = "SchemaRegistry"; @@ -19,15 +19,15 @@ const METHOD_CREATE_SCHEMA: &str = "createSchema"; const METHOD_CREATE_SCHEMA_SIGNED: &str = "createSchemaSigned"; const METHOD_RESOLVE_SCHEMA: &str = "resolveSchema"; -/// Build transaction to execute SchemaRegistry.createSchema contract method to create a new Schema +/// Build a transaction to create a new Schema (SchemaRegistry.createSchema contract method) /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address -/// - `schema` Schema object matching to the specification - https://hyperledger.github.io/anoncreds-spec/#term:schema +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `from`: [Address] - transaction sender account address +/// - `schema`: [Schema] - object matching to the specification - `` /// /// # Returns -/// Write transaction to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_create_schema_transaction( @@ -50,14 +50,14 @@ pub async fn build_create_schema_transaction( .await } -/// Prepared data for execution of SchemaRegistry.createSchema contract method to endorse a new Schema +/// Prepared data for endorsing creation of a new Schema (SchemaRegistry.createSchemaSigned contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `schema` Schema object matching to the specification - https://hyperledger.github.io/anoncreds-spec/#term:schema +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `schema`: [Schema] - object matching to the specification - `` /// /// #Returns -/// data: TransactionEndorsingData - transaction endorsement data to sign +/// data: [TransactionEndorsingData] - transaction endorsement data to sign #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_create_schema_endorsing_data( @@ -65,64 +65,27 @@ pub async fn build_create_schema_endorsing_data( schema: &Schema, ) -> VdrResult { schema.validate()?; - let identity = Address::try_from(&schema.issuer_id)?; TransactionEndorsingDataBuilder::new() .set_contract(CONTRACT_NAME) - .set_identity(&identity) - .add_param(&identity)? - .add_param(&MethodStringParam::from(METHOD_CREATE_SCHEMA))? - .add_param(&schema.id().without_network()?)? - .add_param(&schema.issuer_id.without_network()?)? - .add_param(schema)? - .build(client) - .await -} - -/// Build transaction to execute SchemaRegistry.createSchemaSigned contract method to -/// endorse a new Schema -/// Endorsing version of the method - sender is not identity owner -/// -/// #Params -/// - `client` client connected to the network where contract will be executed -/// - `schema` Schema object matching to the specification - https://hyperledger.github.io/anoncreds-spec/#term:schema -/// - `signature` signature of schema issuer -/// -/// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit -#[logfn(Info)] -#[logfn_inputs(Debug)] -pub async fn build_create_schema_signed_transaction( - client: &LedgerClient, - sender: &Address, - schema: &Schema, - signature: &SignatureData, -) -> VdrResult { - schema.validate()?; - let identity = Address::try_from(&schema.issuer_id)?; - TransactionBuilder::new() - .set_contract(CONTRACT_NAME) - .set_method(METHOD_CREATE_SCHEMA_SIGNED) - .add_param(&identity)? - .add_param(&signature.v())? - .add_param(&signature.r())? - .add_param(&signature.s())? + .set_identity(&Address::try_from(&schema.issuer_id)?) + .set_method(METHOD_CREATE_SCHEMA) + .set_endorsing_method(METHOD_CREATE_SCHEMA_SIGNED) .add_param(&schema.id().without_network()?)? .add_param(&schema.issuer_id.without_network()?)? .add_param(schema)? - .set_type(TransactionType::Write) - .set_from(sender) .build(client) .await } -/// Build transaction to execute SchemaRegistry.resolveSchema contract method to retrieve an existing Schema by the given id +/// Build a transaction to resolve an existing Schema record by the given id +/// (SchemaRegistry.resolveSchema contract method) /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `id` id of Schema to resolve +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `id`: [SchemaId] - id of Schema to resolve /// /// # Returns -/// Read transaction to submit +/// transaction: [Transaction] - prepared read transaction object to submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_resolve_schema_transaction( @@ -141,11 +104,11 @@ pub async fn build_resolve_schema_transaction( /// Parse the result of execution SchemaRegistry.resolveSchema contract method to receive a Schema associated with the id /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns -/// parsed Schema +/// record: [SchemaRecord] - parsed Schema Record #[logfn(Info)] #[logfn_inputs(Debug)] pub fn parse_resolve_schema_result(client: &LedgerClient, bytes: &[u8]) -> VdrResult { @@ -158,11 +121,11 @@ pub fn parse_resolve_schema_result(client: &LedgerClient, bytes: &[u8]) -> VdrRe /// Single step function to resolve a Schema for the given ID /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `id` id of schema to resolve +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `id`: [SchemaId] - id of schema to resolve /// /// # Returns -/// Resolved Schema object +/// schema: [Schema] - Resolved Schema object #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn resolve_schema(client: &LedgerClient, id: &SchemaId) -> VdrResult { @@ -212,7 +175,6 @@ pub mod test { did::types::{did::DID, did_doc::test::TEST_ETHR_DID}, }, }; - use std::sync::RwLock; mod build_create_schema_transaction { use super::*; @@ -255,7 +217,7 @@ pub mod test { 58, 91, 34, 70, 105, 114, 115, 116, 32, 78, 97, 109, 101, 34, 93, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); @@ -305,7 +267,7 @@ pub mod test { 148, 81, 176, 246, 13, 62, 210, 245, 196, 121, 156, 18, 158, 90, 17, 4, 158, 115, 117, 188, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); diff --git a/vdr/src/contracts/anoncreds/types/credential_definition.rs b/vdr/src/contracts/anoncreds/types/credential_definition.rs index bf2f6cd6..fd70deb3 100644 --- a/vdr/src/contracts/anoncreds/types/credential_definition.rs +++ b/vdr/src/contracts/anoncreds/types/credential_definition.rs @@ -7,6 +7,7 @@ use crate::{ use crate::contracts::{anoncreds::types::schema_id::SchemaId, did::types::did::DID}; use serde_derive::{Deserialize, Serialize}; +/// Credential Definition Record stored in the Registry #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct CredentialDefinitionRecord { @@ -16,6 +17,7 @@ pub struct CredentialDefinitionRecord { pub use indy_data_types::anoncreds::cred_def::SignatureType; +/// Definition of AnonCreds Credential Definition object matching to the specification - `` #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct CredentialDefinition { #[serde(rename = "issuerId")] @@ -65,6 +67,15 @@ impl CredentialDefinition { Ok(()) } + pub fn to_string(&self) -> VdrResult { + serde_json::to_string(self).map_err(|err| { + VdrError::InvalidCredentialDefinition(format!( + "Unable to serialize Credential Definition as JSON. Err: {:?}", + err + )) + }) + } + pub fn from_string(value: &str) -> VdrResult { serde_json::from_str(value).map_err(|err| { VdrError::InvalidCredentialDefinition(format!( diff --git a/vdr/src/contracts/anoncreds/types/credential_definition_id.rs b/vdr/src/contracts/anoncreds/types/credential_definition_id.rs index da42660d..06ae3e1e 100644 --- a/vdr/src/contracts/anoncreds/types/credential_definition_id.rs +++ b/vdr/src/contracts/anoncreds/types/credential_definition_id.rs @@ -4,6 +4,7 @@ use crate::contracts::types::did::ParsedDid; use serde_derive::{Deserialize, Serialize}; use sha3::Digest; +/// Wrapper structure for AnonCreds Credential Definition ID #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct CredentialDefinitionId(String); diff --git a/vdr/src/contracts/anoncreds/types/schema.rs b/vdr/src/contracts/anoncreds/types/schema.rs index db6ec790..9b40f768 100644 --- a/vdr/src/contracts/anoncreds/types/schema.rs +++ b/vdr/src/contracts/anoncreds/types/schema.rs @@ -8,6 +8,7 @@ use std::collections::HashSet; use crate::contracts::did::types::did::DID; use serde_derive::{Deserialize, Serialize}; +/// Schema Record stored in the Registry #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct SchemaRecord { @@ -15,6 +16,7 @@ pub struct SchemaRecord { pub metadata: SchemaMetadata, } +/// Definition of AnonCreds Schema object matching to the specification - `` #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Schema { #[serde(rename = "issuerId")] @@ -64,6 +66,15 @@ impl Schema { Ok(()) } + pub fn to_string(&self) -> VdrResult { + serde_json::to_string(self).map_err(|err| { + VdrError::InvalidSchema(format!( + "Unable to serialize Schema as JSON. Err: {:?}", + err + )) + }) + } + pub fn from_string(value: &str) -> VdrResult { serde_json::from_str(value).map_err(|err| { VdrError::InvalidSchema(format!( diff --git a/vdr/src/contracts/anoncreds/types/schema_id.rs b/vdr/src/contracts/anoncreds/types/schema_id.rs index da763ced..d1224c69 100644 --- a/vdr/src/contracts/anoncreds/types/schema_id.rs +++ b/vdr/src/contracts/anoncreds/types/schema_id.rs @@ -4,6 +4,7 @@ use crate::contracts::types::did::ParsedDid; use serde_derive::{Deserialize, Serialize}; use sha3::Digest; +/// Wrapper structure for AnonCreds Schema ID #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct SchemaId(String); diff --git a/vdr/src/contracts/auth/role_control.rs b/vdr/src/contracts/auth/role_control.rs index 865f405a..896dc117 100644 --- a/vdr/src/contracts/auth/role_control.rs +++ b/vdr/src/contracts/auth/role_control.rs @@ -15,13 +15,13 @@ const METHOD_GET_ROLE: &str = "getRole"; /// Build transaction to execute RoleControl.assignRole contract method to assign a role to an account /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address -/// - `role` role to assign -/// - `account` assignee account +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `from`: [Address] - transaction sender account address +/// - `role`: [Role] - role to assign +/// - `account`: [Address] - assignee account /// /// # Returns -/// Write transaction to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_assign_role_transaction( @@ -44,13 +44,13 @@ pub async fn build_assign_role_transaction( /// Build transaction to execute RoleControl.revokeRole contract method to revoke a role from an account /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address -/// - `role` role to assign -/// - `account` revokee account +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `from`: [Address] - transaction sender account address +/// - `role`: [Role] - role to assign +/// - `account`: [Address] - revoke account /// /// # Returns -/// Write transaction to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_revoke_role_transaction( @@ -73,12 +73,12 @@ pub async fn build_revoke_role_transaction( /// Build transaction to execute RoleControl.hasRole contract method to check an account has a role /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `role` role to check -/// - `account` account to check +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `role`: [Role] - role to check +/// - `account`: [Address] - account to check /// /// # Returns -/// Read transaction to submit +/// transaction: [Transaction] - prepared read transaction object to submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_has_role_transaction( @@ -99,11 +99,11 @@ pub async fn build_has_role_transaction( /// Build transaction to execute RoleControl.getRole contract method to get account's role /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `account` account address +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `account`: [Address] - account address /// /// # Returns -/// Read transaction to submit +/// transaction: [Transaction] - prepared read transaction object to submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_get_role_transaction( @@ -122,8 +122,8 @@ pub async fn build_get_role_transaction( /// Parse the result of execution RoleControl.HasRole contract method to check an account has a role /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns /// Account has role result @@ -139,11 +139,11 @@ pub fn parse_has_role_result(client: &LedgerClient, bytes: &[u8]) -> VdrResult VdrResult { @@ -159,7 +159,6 @@ pub mod test { use crate::client::client::test::{ mock_client, CONFIG, DEFAULT_NONCE, TEST_ACCOUNT, TRUSTEE_ACCOUNT, }; - use std::sync::RwLock; pub static ACCOUNT_ROLES: [Role; 4] = [Role::Empty, Role::Trustee, Role::Steward, Role::Endorser]; @@ -192,7 +191,7 @@ pub mod test { nonce: Some(DEFAULT_NONCE.clone()), chain_id: CONFIG.chain_id, data: expected_data, - signature: RwLock::new(None), + signature: None, hash: None, }; @@ -228,7 +227,7 @@ pub mod test { nonce: Some(DEFAULT_NONCE.clone()), chain_id: CONFIG.chain_id, data: expected_data, - signature: RwLock::new(None), + signature: None, hash: None, }; @@ -258,7 +257,7 @@ pub mod test { nonce: None, chain_id: CONFIG.chain_id, data: expected_data, - signature: RwLock::new(None), + signature: None, hash: None, }; @@ -304,7 +303,7 @@ pub mod test { nonce: None, chain_id: CONFIG.chain_id, data: expected_data, - signature: RwLock::new(None), + signature: None, hash: None, }; diff --git a/vdr/src/contracts/auth/types/role.rs b/vdr/src/contracts/auth/types/role.rs index 8d8fa321..2b605831 100644 --- a/vdr/src/contracts/auth/types/role.rs +++ b/vdr/src/contracts/auth/types/role.rs @@ -3,6 +3,7 @@ use crate::{ types::{ContractOutput, ContractParam}, }; +/// Enum listing roles defined on the ledger #[repr(u8)] #[derive(Clone, Copy, PartialEq, Debug)] pub enum Role { diff --git a/vdr/src/contracts/did/did_ethr_registry.rs b/vdr/src/contracts/did/did_ethr_registry.rs index 6ea3a008..cdec330d 100644 --- a/vdr/src/contracts/did/did_ethr_registry.rs +++ b/vdr/src/contracts/did/did_ethr_registry.rs @@ -8,11 +8,11 @@ use crate::{ }, error::VdrResult, types::{ - Address, EventLog, EventParser, EventQuery, EventQueryBuilder, MethodStringParam, - MethodUintBytesParam, Transaction, TransactionBuilder, TransactionEndorsingDataBuilder, - TransactionParser, TransactionType, + Address, EventLog, EventParser, EventQuery, EventQueryBuilder, MethodUintBytesParam, + Transaction, TransactionBuilder, TransactionEndorsingDataBuilder, TransactionParser, + TransactionType, }, - Block, Nonce, SignatureData, TransactionEndorsingData, VdrError, DID, + Block, Nonce, TransactionEndorsingData, VdrError, DID, }; const CONTRACT_NAME: &str = "EthereumExtDidRegistry"; @@ -37,20 +37,16 @@ const EVENT_DID_OWNER_CHANGED: &str = "DIDOwnerChanged"; pub const ETHR_DID_METHOD: &str = "ethr"; -// TODO: In current implementation all methods accept DID but contract API accept identity account address -// Should we change it? - -/// Build transaction to execute EthereumExtDidRegistry.changeOwner contract method to -/// change the owner of ether DID +/// Build a transaction to change the owner of a DID (EthereumExtDidRegistry.changeOwner contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `sender` sender account address (Must be DID owner) -/// - `did` DID to change ownership -/// - `new_owner` account address of new owner +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `sender`: [Address] - sender account address (Must be DID owner) +/// - `did`: [DID] - DID to change ownership +/// - `new_owner`: [Address] - account address of new owner /// /// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_did_change_owner_transaction( @@ -71,15 +67,15 @@ pub async fn build_did_change_owner_transaction( .await } -/// Prepared data for endorsing EthereumExtDidRegistry.changeOwner contract method +/// Prepared data for endorsing a change of a DID owner (EthereumExtDidRegistry.changeOwnerSigned contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `did` DID to change ownership -/// - `new_owner` account address of new owner +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - DID to change ownership +/// - `new_owner`: [Address] - account address of new owner /// /// #Returns -/// data: TransactionEndorsingData - transaction endorsement data to sign +/// data: [TransactionEndorsingData] - transaction endorsement data to sign #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_did_change_owner_endorsing_data( @@ -92,64 +88,27 @@ pub async fn build_did_change_owner_endorsing_data( TransactionEndorsingDataBuilder::new() .set_contract(CONTRACT_NAME) .set_identity(&identity) - .add_param(&nonce)? - .add_param(&identity)? - .add_param(&MethodStringParam::from(METHOD_CHANGE_OWNER))? - .add_param(new_owner)? - .build(client) - .await -} - -/// Build transaction to execute EthereumExtDidRegistry.changeOwnerSigned contract method to -/// change the owner of ether DID -/// Endorsing version of the method - sender is not identity owner -/// -/// #Params -/// - `client` client connected to the network where contract will be executed -/// - `sender` sender account address -/// - `did` DID to change ownership -/// - `new_owner` account address of new owner -/// - `signature` signature of DID identity owner -/// -/// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit -#[logfn(Info)] -#[logfn_inputs(Debug)] -pub async fn build_did_change_owner_signed_transaction( - client: &LedgerClient, - sender: &Address, - did: &DID, - new_owner: &Address, - signature: &SignatureData, -) -> VdrResult { - let identity = Address::try_from(did)?; - TransactionBuilder::new() - .set_contract(CONTRACT_NAME) - .set_method(METHOD_CHANGE_OWNER_SIGNED) - .add_param(&identity)? - .add_param(&signature.v())? - .add_param(&signature.r())? - .add_param(&signature.s())? + .set_nonce(&nonce) + .set_method(METHOD_CHANGE_OWNER) + .set_endorsing_method(METHOD_CHANGE_OWNER_SIGNED) .add_param(new_owner)? - .set_type(TransactionType::Write) - .set_from(sender) .build(client) .await } -/// Build transaction to execute EthereumExtDidRegistry.addDelegate contract method to add a delegate. +/// Build a transaction to add a DID delegate (EthereumExtDidRegistry.addDelegate contract method) /// An identity can assign multiple delegates to manage signing on their behalf for specific purposes. /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `sender` sender account address (Must be DID owner) -/// - `did` DID to add a delegate -/// - `delegate_type` type of delegation (`veriKey` or `sigAuth`) -/// - `delegate` account address of delegate -/// - `validity` delegate validity time +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `sender`: [Address] - sender account address (Must be DID owner) +/// - `did`: [DID] - DID to add a delegate +/// - `delegate_type`: [DelegateType] - type of delegation (`veriKey` or `sigAuth`) +/// - `delegate`: [Address] - account address of delegate +/// - `validity`: [Validity] - delegate validity time /// /// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_did_add_delegate_transaction( @@ -174,17 +133,18 @@ pub async fn build_did_add_delegate_transaction( .await } -/// Prepared data for endorsing EthereumExtDidRegistry.addDelegate contract method +/// Prepared data for endorsing adding of a DID delegate (EthereumExtDidRegistry.addDelegateSigned contract method) +/// An identity can assign multiple delegates to manage signing on their behalf for specific purposes. /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `did` DID to add a delegate -/// - `delegate_type` type of delegation (`veriKey` or `sigAuth`) -/// - `delegate` account address of delegate -/// - `validity` delegate validity time +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - DID to add a delegate +/// - `delegate_type`: [DelegateType] - type of delegation (`veriKey` or `sigAuth`) +/// - `delegate`: [Address] - account address of delegate +/// - `validity`: [Validity] - delegate validity time /// /// #Returns -/// data: TransactionEndorsingData - transaction endorsement data to sign +/// data: [TransactionEndorsingData] - transaction endorsement data to sign #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_did_add_delegate_endorsing_data( @@ -199,9 +159,9 @@ pub async fn build_did_add_delegate_endorsing_data( TransactionEndorsingDataBuilder::new() .set_contract(CONTRACT_NAME) .set_identity(&identity) - .add_param(&nonce)? - .add_param(&identity)? - .add_param(&MethodStringParam::from(METHOD_ADD_DELEGATE))? + .set_nonce(&nonce) + .set_method(METHOD_ADD_DELEGATE) + .set_endorsing_method(METHOD_ADD_DELEGATE_SIGNED) .add_param(delegate_type)? .add_param(delegate)? .add_param(&MethodUintBytesParam::from(validity.0))? @@ -209,62 +169,18 @@ pub async fn build_did_add_delegate_endorsing_data( .await } -/// Build transaction to execute EthereumExtDidRegistry.addDelegateSigned contract method to add a delegate. -/// An identity can assign multiple delegates to manage signing on their behalf for specific purposes. -/// -/// Endorsing version of the method - sender is not identity owner -/// -/// #Params -/// - `client` client connected to the network where contract will be executed -/// - `sender` sender account address -/// - `did` DID to add a delegate -/// - `delegate_type` type of delegation (`veriKey` or `sigAuth`) -/// - `delegate` account address of delegate -/// - `validity` delegate validity time -/// - `signature` signature of DID identity owner -/// -/// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit -#[logfn(Info)] -#[logfn_inputs(Debug)] -pub async fn build_did_add_delegate_signed_transaction( - client: &LedgerClient, - sender: &Address, - did: &DID, - delegate_type: &DelegateType, - delegate: &Address, - validity: &Validity, - signature: &SignatureData, -) -> VdrResult { - let identity = Address::try_from(did)?; - TransactionBuilder::new() - .set_contract(CONTRACT_NAME) - .set_method(METHOD_ADD_DELEGATE_SIGNED) - .add_param(&identity)? - .add_param(&signature.v())? - .add_param(&signature.r())? - .add_param(&signature.s())? - .add_param(delegate_type)? - .add_param(delegate)? - .add_param(validity)? - .set_type(TransactionType::Write) - .set_from(sender) - .build(client) - .await -} - -/// Build transaction to execute EthereumExtDidRegistry.revokeDelegate contract method to revoke a delegate. +/// Build a transaction to revoke a DID delegate (EthereumExtDidRegistry.revokeDelegate contract method) /// An identity can assign multiple delegates to manage signing on their behalf for specific purposes. /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `sender` sender account address (Must be DID owner) -/// - `did` DID to revoke a delegate -/// - `delegate_type` type of delegation (`veriKey` or `sigAuth`) -/// - `delegate` account address of delegate +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `sender`: [Address] - sender account address (Must be DID owner) +/// - `did`: [DID] - DID to revoke a delegate +/// - `delegate_type`: [DelegateType] - type of delegation (`veriKey` or `sigAuth`) +/// - `delegate`: [Address] - account address of delegate /// /// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_did_revoke_delegate_transaction( @@ -287,16 +203,16 @@ pub async fn build_did_revoke_delegate_transaction( .await } -/// Prepared data for endorsing EthereumExtDidRegistry.revokeDelegate contract method +/// Prepared data for endorsing revocation of a DID delegate (EthereumExtDidRegistry.revokeDelegateSigned contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `did` DID to add a delegate -/// - `delegate_type` type of delegation (`veriKey` or `sigAuth`) -/// - `delegate` account address of delegate +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - DID to add a delegate +/// - `delegate_type`: [DelegateType] - type of delegation (`veriKey` or `sigAuth`) +/// - `delegate`: [Address] - account address of delegate /// /// #Returns -/// data: TransactionEndorsingData - transaction endorsement data to sign +/// data: [TransactionEndorsingData] - transaction endorsement data to sign #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_did_revoke_delegate_endorsing_data( @@ -310,70 +226,28 @@ pub async fn build_did_revoke_delegate_endorsing_data( TransactionEndorsingDataBuilder::new() .set_contract(CONTRACT_NAME) .set_identity(&identity) - .add_param(&nonce)? - .add_param(&identity)? - .add_param(&MethodStringParam::from(METHOD_REVOKE_DELEGATE))? - .add_param(delegate_type)? - .add_param(delegate)? - .build(client) - .await -} - -/// Build transaction to execute EthereumExtDidRegistry.revokeDelegateSigned contract method to revoke a delegate. -/// An identity can assign multiple delegates to manage signing on their behalf for specific purposes. -/// -/// Endorsing version of the method - sender is not identity owner -/// -/// #Params -/// - `client` client connected to the network where contract will be executed -/// - `sender` sender account address -/// - `did` DID to revoke a delegate -/// - `delegate_type` type of delegation (`veriKey` or `sigAuth`) -/// - `delegate` account address of delegate -/// - `signature` signature of DID identity owner -/// -/// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit -#[logfn(Info)] -#[logfn_inputs(Debug)] -pub async fn build_did_revoke_delegate_signed_transaction( - client: &LedgerClient, - sender: &Address, - did: &DID, - delegate_type: &DelegateType, - delegate: &Address, - signature: &SignatureData, -) -> VdrResult { - let identity = Address::try_from(did)?; - TransactionBuilder::new() - .set_contract(CONTRACT_NAME) - .set_method(METHOD_REVOKE_DELEGATE_SIGNED) - .add_param(&identity)? - .add_param(&signature.v())? - .add_param(&signature.r())? - .add_param(&signature.s())? + .set_nonce(&nonce) + .set_method(METHOD_REVOKE_DELEGATE) + .set_endorsing_method(METHOD_REVOKE_DELEGATE_SIGNED) .add_param(delegate_type)? .add_param(delegate)? - .set_type(TransactionType::Write) - .set_from(sender) .build(client) .await } -/// Build transaction to execute EthereumExtDidRegistry.setAttribute contract method to add -/// a non ledger DID associated attribute. +/// Build a transaction to add a non ledger DID associated attribute (EthereumExtDidRegistry.setAttribute contract method) /// An identity may need to publish some information that is only needed off-chain but /// still requires the security benefits of using a blockchain. /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `sender` sender account address (Must be DID owner) -/// - `did` DID to add an attribute -/// - `attribute` attribute to add -/// - `validity` attribute validity time +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `sender`: [Address] - sender account address (Must be DID owner) +/// - `did`: [DID] - DID to add an attribute +/// - `attribute`: [DidDocAttribute] - attribute to add +/// - `validity`: [Validity] - attribute validity time /// /// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_did_set_attribute_transaction( @@ -397,16 +271,18 @@ pub async fn build_did_set_attribute_transaction( .await } -/// Prepared data for endorsing EthereumExtDidRegistry.setAttribute contract method +/// Prepared data for endorsing adding of a non ledger DID associated attribute (EthereumExtDidRegistry.setAttributeSigned contract method) +/// An identity may need to publish some information that is only needed off-chain but +/// still requires the security benefits of using a blockchain. /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `did` DID to add an attribute -/// - `attribute` attribute to add -/// - `validity` attribute validity time +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - DID to add an attribute +/// - `attribute`: [DidDocAttribute] - attribute to add +/// - `validity`: [Validity] - attribute validity time /// /// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_did_set_attribute_endorsing_data( @@ -420,73 +296,29 @@ pub async fn build_did_set_attribute_endorsing_data( TransactionEndorsingDataBuilder::new() .set_contract(CONTRACT_NAME) .set_identity(&identity) - .add_param(&nonce)? - .add_param(&identity)? - .add_param(&MethodStringParam::from(METHOD_SET_ATTRIBUTE))? - .add_param(&attribute.name()?)? - .add_param(&attribute.value()?)? - .add_param(&MethodUintBytesParam::from(validity.0))? - .build(client) - .await -} - -/// Build transaction to execute EthereumExtDidRegistry.setAttributeSigned contract method to add -/// a non ledger DID associated attribute. -/// An identity may need to publish some information that is only needed off-chain but -/// still requires the security benefits of using a blockchain. -/// -/// Endorsing version of the method - sender is not identity owner -/// -/// #Params -/// - `client` client connected to the network where contract will be executed -/// - `sender` sender account address -/// - `did` DID to add an attribute -/// - `attribute` attribute to add -/// - `validity` attribute validity time -/// - `signature` signature of DID identity owner -/// -/// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit -#[logfn(Info)] -#[logfn_inputs(Debug)] -pub async fn build_did_set_attribute_signed_transaction( - client: &LedgerClient, - sender: &Address, - did: &DID, - attribute: &DidDocAttribute, - validity: &Validity, - signature: &SignatureData, -) -> VdrResult { - let identity = Address::try_from(did)?; - TransactionBuilder::new() - .set_contract(CONTRACT_NAME) - .set_method(METHOD_SET_ATTRIBUTE_SIGNED) - .add_param(&identity)? - .add_param(&signature.v())? - .add_param(&signature.r())? - .add_param(&signature.s())? + .set_nonce(&nonce) + .set_method(METHOD_SET_ATTRIBUTE) + .set_endorsing_method(METHOD_SET_ATTRIBUTE_SIGNED) .add_param(&attribute.name()?)? .add_param(&attribute.value()?)? .add_param(validity)? - .set_type(TransactionType::Write) - .set_from(sender) .build(client) .await } -/// Build transaction to execute EthereumExtDidRegistry.revokeAttribute contract method to revoke +/// Build a transaction to revoke a non ledger DID associated attribute (EthereumExtDidRegistry.revokeAttribute contract method) /// a non ledger DID associated attribute. /// An identity may need to publish some information that is only needed off-chain but /// still requires the security benefits of using a blockchain. /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `sender` sender account address (Must be DID owner) -/// - `did` DID to revoke an attribute -/// - `attribute` attribute to add +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `sender`: [Address] - sender account address (Must be DID owner) +/// - `did`: [DID] - DID to revoke an attribute +/// - `attribute`: [DidDocAttribute] - attribute to revoke /// /// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_did_revoke_attribute_transaction( @@ -508,15 +340,15 @@ pub async fn build_did_revoke_attribute_transaction( .await } -/// Prepared data for endorsing EthereumExtDidRegistry.revokeAttribute contract method +/// Prepared data for endorsing revocation of a non ledger DID associated attribute (EthereumExtDidRegistry.revokeAttributeSigned contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `did` DID to add an attribute -/// - `attribute` attribute to add +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - DID to add an attribute +/// - `attribute`: [DidDocAttribute] - attribute to revoke /// /// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_did_revoke_attribute_endorsing_data( @@ -529,65 +361,23 @@ pub async fn build_did_revoke_attribute_endorsing_data( TransactionEndorsingDataBuilder::new() .set_contract(CONTRACT_NAME) .set_identity(&identity) - .add_param(&nonce)? - .add_param(&identity)? - .add_param(&MethodStringParam::from(METHOD_REVOKE_ATTRIBUTE))? - .add_param(&attribute.name()?)? - .add_param(&attribute.value()?)? - .build(client) - .await -} - -/// Build transaction to execute EthereumExtDidRegistry.revokeAttributeSigned contract method to revoke -/// a non ledger DID associated attribute. -/// An identity may need to publish some information that is only needed off-chain but -/// still requires the security benefits of using a blockchain. -/// -/// Endorsing version of the method - sender is not identity owner -/// -/// #Params -/// - `client` client connected to the network where contract will be executed -/// - `sender` sender account address -/// - `did` DID to revoke an attribute -/// - `attribute` attribute to add -/// - `signature` signature of DID identity owner -/// -/// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit -#[logfn(Info)] -#[logfn_inputs(Debug)] -pub async fn build_did_revoke_attribute_signed_transaction( - client: &LedgerClient, - sender: &Address, - did: &DID, - attribute: &DidDocAttribute, - signature: &SignatureData, -) -> VdrResult { - let identity = Address::try_from(did)?; - TransactionBuilder::new() - .set_contract(CONTRACT_NAME) - .set_method(METHOD_REVOKE_ATTRIBUTE_SIGNED) - .add_param(&identity)? - .add_param(&signature.v())? - .add_param(&signature.r())? - .add_param(&signature.s())? + .set_nonce(&nonce) + .set_method(METHOD_REVOKE_ATTRIBUTE) + .set_endorsing_method(METHOD_REVOKE_ATTRIBUTE_SIGNED) .add_param(&attribute.name()?)? .add_param(&attribute.value()?)? - .set_type(TransactionType::Write) - .set_from(sender) .build(client) .await } -/// Build transaction to execute EthereumExtDidRegistry.owners contract method to get -/// an account address owning the DID. +/// Build a transaction to get an account address owning the DID (EthereumExtDidRegistry.owners contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `did` target DID +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - target DID /// /// #Returns -/// transaction: Transaction - prepared read transaction object to submit +/// transaction: [Transaction] - prepared read transaction object to submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_get_did_owner_transaction( @@ -604,15 +394,14 @@ pub async fn build_get_did_owner_transaction( .await } -/// Build transaction to execute EthereumExtDidRegistry.changed contract method to get -/// block number when DID was changed last time +/// Build a transaction to get block number when DID was changed last time (EthereumExtDidRegistry.changed contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `did` target DID +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - target DID /// /// #Returns -/// transaction: Transaction - prepared read transaction object to submit +/// transaction: [Transaction] - prepared read transaction object to submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_get_did_changed_transaction( @@ -629,15 +418,14 @@ pub async fn build_get_did_changed_transaction( .await } -/// Build transaction to execute EthereumExtDidRegistry.nonce contract method to get signing -/// nonce needed for endorsement +/// Build a transaction to get signing nonce needed for endorsement (EthereumExtDidRegistry.nonce contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `did` target DID +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - target DID /// /// #Returns -/// transaction: Transaction - prepared read transaction object to submit +/// transaction: [Transaction] - prepared read transaction object to submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_get_identity_nonce_transaction( @@ -656,13 +444,13 @@ pub async fn build_get_identity_nonce_transaction( /// Build event query to obtain log DID associated events from the ledger /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `did` target DID -/// - `from_block` start block -/// - `to_block` finish block +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - target DID +/// - `from_block`: [Block] - start block +/// - `to_block`: [Block] - finish block /// /// #Returns -/// query: EventQuery - prepared event query to send +/// query: [EventQuery] - prepared event query to send #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_get_did_events_query( @@ -684,11 +472,11 @@ pub async fn build_get_did_events_query( /// a block number when DID was changed last time /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns -/// Block number +/// block: [Block] Block number #[logfn(Info)] #[logfn_inputs(Debug)] pub fn parse_did_changed_result(client: &LedgerClient, bytes: &[u8]) -> VdrResult { @@ -702,11 +490,11 @@ pub fn parse_did_changed_result(client: &LedgerClient, bytes: &[u8]) -> VdrResul /// an account address owning the DID. /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns -/// Owner account address +/// owner: [Address] Owner account address #[logfn(Info)] #[logfn_inputs(Debug)] pub fn parse_did_owner_result(client: &LedgerClient, bytes: &[u8]) -> VdrResult
{ @@ -720,11 +508,11 @@ pub fn parse_did_owner_result(client: &LedgerClient, bytes: &[u8]) -> VdrResult< /// a signing nonce needed for endorsement /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns -/// Nonce to use for endorsing +/// nonce: [Nonce] Nonce to use for endorsing #[logfn(Info)] #[logfn_inputs(Debug)] pub fn parse_did_nonce_result(client: &LedgerClient, bytes: &[u8]) -> VdrResult { @@ -737,11 +525,11 @@ pub fn parse_did_nonce_result(client: &LedgerClient, bytes: &[u8]) -> VdrResult< /// Parse DidAttributeChangedEvent from the event log. /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns -/// Parsed DidAttributeChanged event object +/// event: [DidAttributeChanged] - Parsed DidAttributeChanged event object #[logfn(Info)] #[logfn_inputs(Debug)] pub fn parse_did_attribute_changed_event_response( @@ -757,11 +545,11 @@ pub fn parse_did_attribute_changed_event_response( /// Parse DidDelegateChangedEvent from the event log. /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns -/// Parsed DidDelegateChanged event object +/// event: [DidDelegateChanged] Parsed DidDelegateChanged event object #[logfn(Info)] #[logfn_inputs(Debug)] pub fn parse_did_delegate_changed_event_response( @@ -777,11 +565,11 @@ pub fn parse_did_delegate_changed_event_response( /// Parse DidOwnerChangedEvent from the event log. /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns -/// Parsed DidOwnerChanged event object +/// event: [DidOwnerChanged] Parsed DidOwnerChanged event object #[logfn(Info)] #[logfn_inputs(Debug)] pub fn parse_did_owner_changed_event_response( @@ -797,11 +585,11 @@ pub fn parse_did_owner_changed_event_response( /// Parse DID associated event from the event log (it can be one of: DidAttributeChanged, DidDelegateChanged, DidOwnerChanged). /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns -/// Parsed DID event object +/// event: [DidEvents] Parsed DID event object #[logfn(Info)] #[logfn_inputs(Debug)] pub fn parse_did_event_response(client: &LedgerClient, event: &EventLog) -> VdrResult { @@ -839,7 +627,7 @@ pub fn parse_did_event_response(client: &LedgerClient, event: &EventLog) -> VdrR #[logfn(Info)] #[logfn_inputs(Debug)] -pub async fn resolve_identity_nonce(client: &LedgerClient, identity: &Address) -> VdrResult { +async fn resolve_identity_nonce(client: &LedgerClient, identity: &Address) -> VdrResult { let transaction = build_get_identity_nonce_transaction(client, identity).await?; let response = client.submit_transaction(&transaction).await?; parse_did_nonce_result(client, &response) @@ -861,7 +649,6 @@ pub mod test { ServiceEndpoint, }, }; - use std::sync::RwLock; fn did() -> DID { DID::from(format!("did:ethr:{}", TEST_ACCOUNT.as_ref()).as_str()) @@ -935,7 +722,7 @@ pub mod test { 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 226, 219, 108, 141, 198, 198, 129, 187, 93, 106, 209, 33, 161, 7, 243, 0, 233, 178, 181, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); @@ -973,7 +760,7 @@ pub mod test { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 232, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); @@ -1008,7 +795,7 @@ pub mod test { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 226, 219, 108, 141, 198, 198, 129, 187, 93, 106, 209, 33, 161, 7, 243, 0, 233, 178, 181, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); @@ -1047,7 +834,7 @@ pub mod test { 0, 0, 0, 18, 104, 116, 116, 112, 58, 47, 47, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); @@ -1083,7 +870,7 @@ pub mod test { 20, 103, 236, 224, 41, 108, 66, 163, 228, 133, 29, 248, 18, 225, 230, 17, 163, 84, 230, 43, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); @@ -1116,7 +903,7 @@ pub mod test { 116, 112, 58, 47, 47, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); diff --git a/vdr/src/contracts/did/did_indy_registry.rs b/vdr/src/contracts/did/did_indy_registry.rs index f8b2039b..eccde1ac 100644 --- a/vdr/src/contracts/did/did_indy_registry.rs +++ b/vdr/src/contracts/did/did_indy_registry.rs @@ -8,10 +8,10 @@ use crate::{ }, error::VdrResult, types::{ - Address, MethodStringParam, Transaction, TransactionBuilder, - TransactionEndorsingDataBuilder, TransactionParser, TransactionType, + Address, Transaction, TransactionBuilder, TransactionEndorsingDataBuilder, + TransactionParser, TransactionType, }, - SignatureData, TransactionEndorsingData, + TransactionEndorsingData, }; const CONTRACT_NAME: &str = "IndyDidRegistry"; @@ -25,16 +25,16 @@ const METHOD_RESOLVE_DID: &str = "resolveDid"; pub const INDYBESU_DID_METHOD: &str = "indybesu"; -/// Build transaction to execute IndyDidRegistry.createDid contract method to create a new DID +/// Build a transaction to create a new DID record (IndyDidRegistry.createDid contract method) /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address -/// - `did` DID to create. -/// - `did_doc` DID Document matching to the specification: https://www.w3.org/TR/did-core/ +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `from`: [Address] - transaction sender account address +/// - `did`: [DID] - DID to create. +/// - `did_doc`: [DidDocument] - DID Document matching to the specification: `` /// /// # Returns -/// Write transaction to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_create_did_transaction( @@ -43,11 +43,10 @@ pub async fn build_create_did_transaction( did: &DID, did_doc: &DidDocument, ) -> VdrResult { - let identity = Address::try_from(did)?; TransactionBuilder::new() .set_contract(CONTRACT_NAME) .set_method(METHOD_CREATE_DID) - .add_param(&identity)? + .add_param(&Address::try_from(did)?)? .add_param(did_doc)? .set_type(TransactionType::Write) .set_from(from) @@ -55,14 +54,15 @@ pub async fn build_create_did_transaction( .await } -/// Prepared data for endorsing IndyDidRegistry.createDid contract method +/// Prepared data for endorsing creation of a new DID record (IndyDidRegistry.createDidSigned contract method) /// /// #Params -/// - `did` DID to create. -/// - `did_doc` DID Document matching to the specification: https://www.w3.org/TR/did-core/ +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - DID to create. +/// - `did_doc`: [DidDocument] - DID Document matching to the specification: `` /// /// #Returns -/// data: TransactionEndorsingData - transaction endorsement data to sign +/// data: [TransactionEndorsingData] - transaction endorsement data to sign #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_create_did_endorsing_data( @@ -70,63 +70,26 @@ pub async fn build_create_did_endorsing_data( did: &DID, did_doc: &DidDocument, ) -> VdrResult { - let identity = Address::try_from(did)?; TransactionEndorsingDataBuilder::new() .set_contract(CONTRACT_NAME) - .set_identity(&identity) - .add_param(&identity)? - .add_param(&MethodStringParam::from(METHOD_CREATE_DID))? - .add_param(did_doc)? - .build(client) - .await -} - -/// Build transaction to execute IndyDidRegistry.createDidSigned contract method to endorse a new DID -/// Endorsing version of the method - sender is not identity owner -/// -/// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address -/// - `did` DID to create. -/// - `did_doc` DID Document matching to the specification: https://www.w3.org/TR/did-core/ -/// - `signature` signature of DID identity owner -/// -/// # Returns -/// Write transaction to sign and submit -#[logfn(Info)] -#[logfn_inputs(Debug)] -pub async fn build_create_did_signed_transaction( - client: &LedgerClient, - from: &Address, - did: &DID, - did_doc: &DidDocument, - signature: &SignatureData, -) -> VdrResult { - let identity = Address::try_from(did)?; - TransactionBuilder::new() - .set_contract(CONTRACT_NAME) - .set_method(METHOD_CREATE_DID_SIGNED) - .add_param(&identity)? - .add_param(&signature.v())? - .add_param(&signature.r())? - .add_param(&signature.s())? + .set_identity(&Address::try_from(did)?) + .set_method(METHOD_CREATE_DID) + .set_endorsing_method(METHOD_CREATE_DID_SIGNED) .add_param(did_doc)? - .set_type(TransactionType::Write) - .set_from(from) .build(client) .await } -/// Build transaction to execute IndyDidRegistry.updateDid contract method to update DID document for an existing DID +/// Build a transaction to update an existing DID record (IndyDidRegistry.updateDid contract method) /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address -/// - `did` DID to update. -/// - `did_doc` DID Document matching to the specification: https://www.w3.org/TR/did-core/ +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `from`: [Address] - transaction sender account address +/// - `did`: [DID] - DID to update. +/// - `did_doc`: [DidDocument] - DID Document matching to the specification: `` /// /// # Returns -/// Write transaction to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_update_did_transaction( @@ -135,11 +98,10 @@ pub async fn build_update_did_transaction( did: &DID, did_doc: &DidDocument, ) -> VdrResult { - let identity = Address::try_from(did)?; TransactionBuilder::new() .set_contract(CONTRACT_NAME) .set_method(METHOD_UPDATE_DID) - .add_param(&identity)? + .add_param(&Address::try_from(did)?)? .add_param(did_doc)? .set_type(TransactionType::Write) .set_from(from) @@ -147,14 +109,15 @@ pub async fn build_update_did_transaction( .await } -/// Prepared data for endorsing IndyDidRegistry.updateDid contract method +/// Prepared data for endorsing update of an existing DID record (IndyDidRegistry.updateDidSigned contract method) /// /// #Params -/// - `did` DID to create. -/// - `did_doc` DID Document matching to the specification: https://www.w3.org/TR/did-core/ +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - DID to create. +/// - `did_doc`: [DidDocument] - DID Document matching to the specification: `` /// /// #Returns -/// data: TransactionEndorsingData - transaction endorsement data to sign +/// data: [TransactionEndorsingData] - transaction endorsement data to sign #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_update_did_endorsing_data( @@ -162,62 +125,25 @@ pub async fn build_update_did_endorsing_data( did: &DID, did_doc: &DidDocument, ) -> VdrResult { - let identity = Address::try_from(did)?; TransactionEndorsingDataBuilder::new() .set_contract(CONTRACT_NAME) - .set_identity(&identity) - .add_param(&identity)? - .add_param(&MethodStringParam::from(METHOD_UPDATE_DID))? - .add_param(did_doc)? - .build(client) - .await -} - -/// Build transaction to execute IndyDidRegistry.updateDidSigned contract method to update DID document for an existing DID -/// Endorsing version of the method - sender is not identity owner -/// -/// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address -/// - `did` DID to create. -/// - `did_doc` DID Document matching to the specification: https://www.w3.org/TR/did-core/ -/// - `signature` signature of DID identity owner -/// -/// # Returns -/// Write transaction to sign and submit -#[logfn(Info)] -#[logfn_inputs(Debug)] -pub async fn build_update_did_signed_transaction( - client: &LedgerClient, - from: &Address, - did: &DID, - did_doc: &DidDocument, - signature: &SignatureData, -) -> VdrResult { - let identity = Address::try_from(did)?; - TransactionBuilder::new() - .set_contract(CONTRACT_NAME) - .set_method(METHOD_UPDATE_DID_SIGNED) - .add_param(&identity)? - .add_param(&signature.v())? - .add_param(&signature.r())? - .add_param(&signature.s())? + .set_identity(&Address::try_from(did)?) + .set_method(METHOD_UPDATE_DID) + .set_endorsing_method(METHOD_UPDATE_DID_SIGNED) .add_param(did_doc)? - .set_type(TransactionType::Write) - .set_from(from) .build(client) .await } -/// Build transaction to execute IndyDidRegistry.deactivateDid contract method to deactivate an existing DID +/// Build a transaction to deactivate an existing DID record (IndyDidRegistry.deactivateDid contract method) /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address -/// - `did` DID to deactivate. +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `from`: [Address] - transaction sender account address +/// - `did`: [DID] - DID to deactivate. /// /// # Returns -/// Write transaction to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_deactivate_did_transaction( @@ -225,83 +151,48 @@ pub async fn build_deactivate_did_transaction( from: &Address, did: &DID, ) -> VdrResult { - let identity = Address::try_from(did)?; TransactionBuilder::new() .set_contract(CONTRACT_NAME) .set_method(METHOD_DEACTIVATE_DID) - .add_param(&identity)? + .add_param(&Address::try_from(did)?)? .set_type(TransactionType::Write) .set_from(from) .build(client) .await } -/// Build transaction to execute IndyDidRegistry.deactivateDid contract method to deactivate an existing DID +/// Prepared data for endorsing deactivation of an existing DID record (IndyDidRegistry.deactivateDidSigned contract method) /// /// #Params -/// - `did` DID to create. -/// - `did_doc` DID Document matching to the specification: https://www.w3.org/TR/did-core/ +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - DID to create. +/// - `did_doc`: [DidDocument] - DID Document matching to the specification: `` /// /// #Returns -/// data: TransactionEndorsingData - transaction endorsement data to sign +/// data: [TransactionEndorsingData] - transaction endorsement data to sign #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_deactivate_did_endorsing_data( client: &LedgerClient, did: &DID, ) -> VdrResult { - let identity = Address::try_from(did)?; TransactionEndorsingDataBuilder::new() .set_contract(CONTRACT_NAME) - .set_identity(&identity) - .add_param(&identity)? - .add_param(&MethodStringParam::from(METHOD_DEACTIVATE_DID))? - .build(client) - .await -} - -/// Build transaction to execute IndyDidRegistry.deactivateDidSigned contract method to deactivate an existing DID -/// Endorsing version of the method - sender is not identity owner -/// -/// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address -/// - `did` DID to create. -/// - `did_doc` DID Document matching to the specification: https://www.w3.org/TR/did-core/ -/// - `signature` signature of DID identity owner -/// -/// # Returns -/// Write transaction to sign and submit -#[logfn(Info)] -#[logfn_inputs(Debug)] -pub async fn build_deactivate_did_signed_transaction( - client: &LedgerClient, - from: &Address, - did: &DID, - signature: &SignatureData, -) -> VdrResult { - let identity = Address::try_from(did)?; - TransactionBuilder::new() - .set_contract(CONTRACT_NAME) - .set_method(METHOD_DEACTIVATE_DID_SIGNED) - .add_param(&identity)? - .add_param(&signature.v())? - .add_param(&signature.r())? - .add_param(&signature.s())? - .set_type(TransactionType::Write) - .set_from(from) + .set_identity(&Address::try_from(did)?) + .set_method(METHOD_DEACTIVATE_DID) + .set_endorsing_method(METHOD_DEACTIVATE_DID_SIGNED) .build(client) .await } -/// Build transaction to execute IndyDidRegistry.resolveDid contract method to receive a DID Document associated with the DID +/// Build a transaction to resolve a DID Record (IndyDidRegistry.resolveDid contract method) /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `did` DID to resolve. +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - DID to resolve. /// /// # Returns -/// Read transaction to submit +/// transaction: [Transaction] - prepared read transaction object to submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_resolve_did_transaction( @@ -318,14 +209,14 @@ pub async fn build_resolve_did_transaction( .await } -/// Parse the result of execution IndyDidRegistry.resolveDid contract method to receive a DID Document associated with the DID +/// Parse the result of execution transaction to resolve a DID Record (IndyDidRegistry.resolveDid contract method) /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns -/// parsed DID Record +/// [DidRecord] DID Record containing DID Document and metadata associated with the DID #[logfn(Info)] #[logfn_inputs(Debug)] pub fn parse_resolve_did_result(client: &LedgerClient, bytes: &[u8]) -> VdrResult { @@ -345,7 +236,6 @@ pub mod test { did_doc::test::{did_doc, TEST_ETHR_DID}, }, }; - use std::sync::RwLock; mod build_create_did_transaction { use super::*; @@ -403,7 +293,7 @@ pub mod test { 101, 57, 98, 50, 98, 53, 35, 75, 69, 89, 45, 49, 34, 93, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); @@ -429,7 +319,7 @@ pub mod test { 24, 48, 235, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 226, 219, 108, 141, 198, 198, 129, 187, 93, 106, 209, 33, 161, 7, 243, 0, 233, 178, 181, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); diff --git a/vdr/src/contracts/did/did_resolver.rs b/vdr/src/contracts/did/did_resolver.rs index 2132fb9c..7cbfa6c0 100644 --- a/vdr/src/contracts/did/did_resolver.rs +++ b/vdr/src/contracts/did/did_resolver.rs @@ -22,12 +22,12 @@ use crate::{ /// Single step function to resolve a DidDocument with metadata for the given DID /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `did` DID to get a DID Document and metadata -/// - `options` Resolution options +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - DID to get a DID Document and metadata +/// - `options`: [DidResolutionOptions] - Resolution options /// /// # Returns -/// Parsed DID event object +/// did_with_meta: [DidDocumentWithMeta] - resolved DID Document with associate metadata #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn resolve_did( diff --git a/vdr/src/contracts/did/types/did.rs b/vdr/src/contracts/did/types/did.rs index 9e67286a..5cc8e8fc 100644 --- a/vdr/src/contracts/did/types/did.rs +++ b/vdr/src/contracts/did/types/did.rs @@ -3,6 +3,7 @@ use serde_derive::{Deserialize, Serialize}; pub const DID_PREFIX: &str = "did"; +/// Wrapper structure for DID #[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)] pub struct DID(String); diff --git a/vdr/src/contracts/did/types/did_doc.rs b/vdr/src/contracts/did/types/did_doc.rs index 57ea9fc1..f9890c8d 100644 --- a/vdr/src/contracts/did/types/did_doc.rs +++ b/vdr/src/contracts/did/types/did_doc.rs @@ -13,6 +13,7 @@ pub const SECPK_CONTEXT: &str = "https://w3id.org/security/suites/secp256k1recov pub const KEYS_CONTEXT: &str = "https://w3id.org/security/v3-unstable"; pub const DID_RESOLUTION_FORMAT: &str = "application/did+ld+json"; +/// DID Document with associate metadata #[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct DidDocumentWithMeta { @@ -37,6 +38,7 @@ pub struct DidResolutionOptions { pub block_tag: Option, } +/// Definition of DID Document object matching to the specification - `` #[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct DidDocument { @@ -68,6 +70,7 @@ pub struct DidDocument { pub also_known_as: Option>, } +/// DID Record stored in the IndyBesu DID Registry #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct DidRecord { diff --git a/vdr/src/contracts/did/types/did_doc_attribute.rs b/vdr/src/contracts/did/types/did_doc_attribute.rs index cd8913db..5c28412c 100644 --- a/vdr/src/contracts/did/types/did_doc_attribute.rs +++ b/vdr/src/contracts/did/types/did_doc_attribute.rs @@ -111,6 +111,7 @@ impl TryFrom<&str> for PublicKeyPurpose { } } +/// Enum listing possible DID delegate types #[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)] pub enum DelegateType { #[default] @@ -216,6 +217,7 @@ pub struct ServiceAttribute { pub service_endpoint: ServiceEndpoint, } +/// Enum listing attributes which can be associated with a DID #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[serde(untagged)] pub enum DidDocAttribute { @@ -383,6 +385,7 @@ impl TryFrom<&DidDocAttributeValue> for ContractParam { } } +/// Wrapper structure for DID attribute validity time in seconds #[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)] pub struct Validity(pub(crate) u64); diff --git a/vdr/src/contracts/endorsing.rs b/vdr/src/contracts/endorsing.rs new file mode 100644 index 00000000..8197c9d7 --- /dev/null +++ b/vdr/src/contracts/endorsing.rs @@ -0,0 +1,43 @@ +use crate::{ + types::TransactionBuilder, Address, LedgerClient, Transaction, TransactionEndorsingData, + TransactionType, VdrError, VdrResult, +}; +use log_derive::{logfn, logfn_inputs}; + +/// Build transaction to endorse author prepared transaction +/// +/// # Params +/// - `client` client connected to the network where contract will be executed +/// - `from` transaction sender account address +/// - `endorsing_data` prepared transaction endorsing data. +/// +/// # Returns +/// Write transaction to sign and submit +#[logfn(Info)] +#[logfn_inputs(Debug)] +pub async fn build_endorsement_transaction( + client: &LedgerClient, + from: &Address, + endorsing_data: &TransactionEndorsingData, +) -> VdrResult { + let signature = endorsing_data + .signature + .as_ref() + .ok_or_else(|| { + VdrError::ClientInvalidEndorsementData("Missing author signature".to_string()) + })? + .clone(); + + TransactionBuilder::new() + .set_contract(&endorsing_data.contract) + .set_method(&endorsing_data.endorsing_method) + .add_param(&endorsing_data.from)? + .add_param(&signature.v())? + .add_param(&signature.r())? + .add_param(&signature.s())? + .add_contract_params(endorsing_data.params.as_slice())? + .set_type(TransactionType::Write) + .set_from(from) + .build(client) + .await +} diff --git a/vdr/src/contracts/migration/legacy_mapping_registry.rs b/vdr/src/contracts/migration/legacy_mapping_registry.rs index 9a3af13e..a8de31fd 100644 --- a/vdr/src/contracts/migration/legacy_mapping_registry.rs +++ b/vdr/src/contracts/migration/legacy_mapping_registry.rs @@ -9,10 +9,10 @@ use crate::{ }, error::VdrResult, types::{ - Address, MethodStringParam, Transaction, TransactionBuilder, - TransactionEndorsingDataBuilder, TransactionParser, TransactionType, + Address, Transaction, TransactionBuilder, TransactionEndorsingDataBuilder, + TransactionParser, TransactionType, }, - SignatureData, TransactionEndorsingData, DID, + TransactionEndorsingData, DID, }; const CONTRACT_NAME: &str = "LegacyMappingRegistry"; @@ -23,19 +23,19 @@ const METHOD_CREATE_RESOURCE_MAPPING_SIGNED: &str = "createResourceMappingSigned const METHOD_DID_MAPPING: &str = "didMapping"; const METHOD_RESOURCE_MAPPING: &str = "resourceMapping"; -/// Build transaction to execute LegacyMappingRegistry.createDidMapping contract method to -/// create a legacy DID identifier mapping +/// Build a transaction to create a legacy DID identifier mapping +/// (LegacyMappingRegistry.createDidMapping contract method) /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address (new account) -/// - `did` new DID -/// - `legacy_identifier` identifier of legacy sov/indy DID -/// - `legacy_verkey` Ed25519 verification key of the legacy DID identifier. -/// - `ed25519_signature` ED25519 signature to prove key possession. +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `from`: [Address] - transaction sender account address (new account) +/// - `did`: [DID] - new DID +/// - `legacy_identifier`: [LegacyDid] - identifier of legacy sov/indy DID +/// - `legacy_verkey`: [LegacyVerkey] - Ed25519 verification key of the legacy DID identifier. +/// - `ed25519_signature`: [Ed25519Signature] - ED25519 signature to prove key possession. /// /// # Returns -/// Write transaction to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_create_did_mapping_transaction( @@ -61,17 +61,18 @@ pub async fn build_create_did_mapping_transaction( .await } -/// Prepared data for execution of LegacyMappingRegistry.createDidMapping contract method to endorse a new DID mapping +/// Prepared data for endorsing creation of a legacy DID identifier mapping +/// (LegacyMappingRegistry.createDidMappingSigned contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `did` new DID -/// - `legacy_identifier` identifier of legacy sov/indy DID -/// - `legacy_verkey` Ed25519 verification key of the legacy DID identifier. -/// - `ed25519_signature` ED25519 signature to prove key possession. +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - new DID +/// - `legacy_identifier`: [LegacyDid] - identifier of legacy sov/indy DID +/// - `legacy_verkey`: [LegacyVerkey] - Ed25519 verification key of the legacy DID identifier. +/// - `ed25519_signature`: [Ed25519Signature] - ED25519 signature to prove key possession. /// /// #Returns -/// data: TransactionEndorsingData - transaction endorsement data to sign +/// data: [TransactionEndorsingData] - transaction endorsement data to sign #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_create_did_mapping_endorsing_data( @@ -81,73 +82,28 @@ pub async fn build_create_did_mapping_endorsing_data( legacy_verkey: &LegacyVerkey, ed25519_signature: &Ed25519Signature, ) -> VdrResult { - let identity = Address::try_from(did)?; TransactionEndorsingDataBuilder::new() .set_contract(CONTRACT_NAME) - .set_identity(&identity) - .add_param(&identity)? - .add_param(&MethodStringParam::from(METHOD_CREATE_DID_MAPPING))? - .add_param(legacy_identifier)? - .add_param(&did.without_network()?)? - .add_param(legacy_verkey)? - .add_param(ed25519_signature)? - .build(client) - .await -} - -/// Build transaction to execute LegacyMappingRegistry.createDidMappingSigned contract method to -/// endorse a legacy DID identifier mapping -/// Endorsing version of the method - sender is not identity owner -/// -/// #Params -/// - `client` client connected to the network where contract will be executed -/// - `sender` transaction sender account address (new account) -/// - `did` new DID -/// - `legacy_identifier` identifier of legacy sov/indy DID -/// - `legacy_verkey` Ed25519 verification key of the legacy DID identifier. -/// - `ed25519_signature` ED25519 signature to prove key possession. -/// - `signature` signature of DID identity owner -/// -/// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit -#[logfn(Info)] -#[logfn_inputs(Debug)] -pub async fn build_create_did_mapping_signed_transaction( - client: &LedgerClient, - from: &Address, - did: &DID, - legacy_identifier: &LegacyDid, - legacy_verkey: &LegacyVerkey, - ed25519_signature: &Ed25519Signature, - signature: &SignatureData, -) -> VdrResult { - let identity = Address::try_from(did)?; - TransactionBuilder::new() - .set_contract(CONTRACT_NAME) - .set_method(METHOD_CREATE_DID_MAPPING_SIGNED) - .add_param(&identity)? - .add_param(&signature.v())? - .add_param(&signature.r())? - .add_param(&signature.s())? + .set_identity(&Address::try_from(did)?) + .set_method(METHOD_CREATE_DID_MAPPING) + .set_endorsing_method(METHOD_CREATE_DID_MAPPING_SIGNED) .add_param(legacy_identifier)? .add_param(&did.without_network()?)? .add_param(legacy_verkey)? .add_param(ed25519_signature)? - .set_type(TransactionType::Write) - .set_from(from) .build(client) .await } -/// Build transaction to execute LegacyMappingRegistry.didMapping contract method to get -/// new identity DID for legacy DID identifier +/// Build a transaction to resolve new identity DID for the given legacy DID identifier +/// (LegacyMappingRegistry.didMapping contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `legacy_identifier` identifier of legacy sov/indy DID +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `legacy_identifier`: [LegacyDid] - identifier of legacy sov/indy DID /// /// #Returns -/// transaction: Transaction - prepared read transaction object to submit +/// transaction: [Transaction] - prepared read transaction object to submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_get_did_mapping_transaction( @@ -167,8 +123,8 @@ pub async fn build_get_did_mapping_transaction( /// new identity DID for legacy DID identifier /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns /// Identity DID @@ -181,19 +137,19 @@ pub fn parse_did_mapping_result(client: &LedgerClient, bytes: &[u8]) -> VdrResul .parse::(client, bytes) } -/// Build transaction to execute LegacyMappingRegistry.createResourceMapping contract method to -/// create mapping of legacy schema/credential definition identifier to new one. +/// Build a transaction to create a mapping of legacy schema/credential definition identifier to new one +/// (LegacyMappingRegistry.createResourceMapping contract method) /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address (new account) -/// - `did` new DID -/// - `legacy_issuer_identifier` identifier of legacy sov/indy DID -/// - `legacy_identifier` legacy identifier. -/// - `new_identifier` new identifier. +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `from`: [Address] - transaction sender account address (new account) +/// - `did`: [DID] - new DID +/// - `legacy_issuer_identifier`: [LegacyDid] - identifier of legacy sov/indy DID +/// - `legacy_identifier`: [ResourceIdentifier] - legacy identifier. +/// - `new_identifier`: [ResourceIdentifier] - new identifier. /// /// # Returns -/// Write transaction to sign and submit +/// transaction: [Transaction] - prepared write transaction object to sign and submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_create_resource_mapping_transaction( @@ -218,18 +174,18 @@ pub async fn build_create_resource_mapping_transaction( .await } -/// Prepared data for execution of LegacyMappingRegistry.createResourceMapping contract method to -/// endorse a new resource mapping. +/// Prepared data for endorsing creation of a new resource mapping +/// (LegacyMappingRegistry.createResourceMappingSigned contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `did` new DID -/// - `legacy_issuer_identifier` identifier of legacy sov/indy DID -/// - `legacy_identifier` legacy identifier. -/// - `new_identifier` new identifier. +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `did`: [DID] - new DID +/// - `legacy_issuer_identifier`: [LegacyDid] - identifier of legacy sov/indy DID +/// - `legacy_identifier`: [ResourceIdentifier] - legacy identifier. +/// - `new_identifier`: [ResourceIdentifier] - new identifier. /// /// #Returns -/// data: TransactionEndorsingData - transaction endorsement data to sign +/// data: [TransactionEndorsingData] - transaction endorsement data to sign #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_create_resource_mapping_endorsing_data( @@ -239,70 +195,27 @@ pub async fn build_create_resource_mapping_endorsing_data( legacy_identifier: &ResourceIdentifier, new_identifier: &ResourceIdentifier, ) -> VdrResult { - let identity = Address::try_from(did)?; TransactionEndorsingDataBuilder::new() .set_contract(CONTRACT_NAME) - .set_identity(&identity) - .add_param(&identity)? - .add_param(&MethodStringParam::from(METHOD_CREATE_RESOURCE_MAPPING))? - .add_param(legacy_issuer_identifier)? - .add_param(legacy_identifier)? - .add_param(new_identifier)? - .build(client) - .await -} - -/// Build transaction to execute LegacyMappingRegistry.createResourceMappingSigned contract method to -/// endorse a legacy DID identifier mapping -/// Endorsing version of the method - sender is not identity owner -/// -/// #Params -/// - `client` client connected to the network where contract will be executed -/// - `identity` transaction sender account address (new account) -/// - `legacy_issuer_identifier` identifier of legacy sov/indy DID -/// - `legacy_identifier` legacy identifier. -/// - `new_identifier` new identifier. -/// - `signature` signature of DID identity owner -/// -/// #Returns -/// transaction: Transaction - prepared write transaction object to sign and submit -#[logfn(Info)] -#[logfn_inputs(Debug)] -pub async fn build_create_resource_mapping_signed_transaction( - client: &LedgerClient, - from: &Address, - did: &DID, - legacy_issuer_identifier: &LegacyDid, - legacy_identifier: &ResourceIdentifier, - new_identifier: &ResourceIdentifier, - signature: &SignatureData, -) -> VdrResult { - let identity = Address::try_from(did)?; - TransactionBuilder::new() - .set_contract(CONTRACT_NAME) - .set_method(METHOD_CREATE_RESOURCE_MAPPING_SIGNED) - .add_param(&identity)? - .add_param(&signature.v())? - .add_param(&signature.r())? - .add_param(&signature.s())? + .set_identity(&Address::try_from(did)?) + .set_method(METHOD_CREATE_RESOURCE_MAPPING) + .set_endorsing_method(METHOD_CREATE_RESOURCE_MAPPING_SIGNED) .add_param(legacy_issuer_identifier)? .add_param(legacy_identifier)? .add_param(new_identifier)? - .set_type(TransactionType::Write) - .set_from(from) .build(client) .await } -/// Build transaction to execute LegacyMappingRegistry.resourceMapping contract method to get -/// new identifier for a legacy Schema/CredentialDefinition +/// Build a transaction to resolve new identifier for the given legacy Schema/CredentialDefinition ID +/// (LegacyMappingRegistry.resourceMapping contract method) /// /// #Params -/// - `client` client connected to the network where contract will be executed -/// - `legacy_identifier` identifier of legacy Schema/CredentialDefinition +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `legacy_identifier`: [ResourceIdentifier] - identifier of legacy Schema/CredentialDefinition /// /// #Returns -/// transaction: Transaction - prepared read transaction object to submit +/// transaction: [Transaction] - prepared read transaction object to submit #[logfn(Info)] #[logfn_inputs(Debug)] pub async fn build_get_resource_mapping_transaction( @@ -322,8 +235,8 @@ pub async fn build_get_resource_mapping_transaction( /// new identifier for a legacy Schema/CredentialDefinition /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns /// New identifier @@ -347,8 +260,6 @@ pub mod test { contracts::{did::types::did::DID, types::did_doc::test::TEST_ETHR_DID}, }; - use std::sync::RwLock; - const LEGACY_DID: &str = "VsKV7grR1BUE29mG2Fm2kX"; const LEGACY_VERKEY: &str = "GjZWsBLgZCR18aL468JAT7w9CZRiBnpxUPPgyQxh4voa"; const LEGACY_SCHEMA_ID: &str = "VsKV7grR1BUE29mG2Fm2kX:2:test_credential:1.0.0"; @@ -397,7 +308,7 @@ pub mod test { 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); @@ -427,7 +338,7 @@ pub mod test { 103, 114, 82, 49, 66, 85, 69, 50, 57, 109, 71, 50, 70, 109, 50, 107, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); @@ -478,7 +389,7 @@ pub mod test { 47, 116, 101, 115, 116, 95, 99, 114, 101, 100, 101, 110, 116, 105, 97, 108, 47, 49, 46, 48, 46, 48, 0, 0, 0, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); @@ -511,7 +422,7 @@ pub mod test { 50, 58, 116, 101, 115, 116, 95, 99, 114, 101, 100, 101, 110, 116, 105, 97, 108, 58, 49, 46, 48, 46, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], - signature: RwLock::new(None), + signature: None, hash: None, }; assert_eq!(expected_transaction, transaction); diff --git a/vdr/src/contracts/migration/types/did.rs b/vdr/src/contracts/migration/types/did.rs index bf674e22..325f847f 100644 --- a/vdr/src/contracts/migration/types/did.rs +++ b/vdr/src/contracts/migration/types/did.rs @@ -1,6 +1,7 @@ use crate::{types::ContractParam, VdrError}; use serde_derive::{Deserialize, Serialize}; +/// Wrapper structure for legacy Indy DID identifier #[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)] pub struct LegacyDid(String); @@ -30,6 +31,7 @@ impl TryFrom<&LegacyDid> for ContractParam { } } +/// Wrapper structure for legacy ED25519 verification key #[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)] pub struct LegacyVerkey(String); diff --git a/vdr/src/contracts/migration/types/ed25519_signature.rs b/vdr/src/contracts/migration/types/ed25519_signature.rs index fa8b018c..81794c5c 100644 --- a/vdr/src/contracts/migration/types/ed25519_signature.rs +++ b/vdr/src/contracts/migration/types/ed25519_signature.rs @@ -1,5 +1,6 @@ use crate::{types::ContractParam, VdrError}; +/// Wrapper structure for ED25519 signature #[derive(Debug, Default)] pub struct Ed25519Signature(Vec); diff --git a/vdr/src/contracts/migration/types/resource_identifier.rs b/vdr/src/contracts/migration/types/resource_identifier.rs index 5799ca7a..cce0ec36 100644 --- a/vdr/src/contracts/migration/types/resource_identifier.rs +++ b/vdr/src/contracts/migration/types/resource_identifier.rs @@ -4,6 +4,7 @@ use crate::{ }; use serde::{Deserialize, Serialize}; +/// Wrapper structure for resource identifier (Schema Id / Credential Definition Id) #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct ResourceIdentifier(String); diff --git a/vdr/src/contracts/mod.rs b/vdr/src/contracts/mod.rs index 94202f26..71ad305c 100644 --- a/vdr/src/contracts/mod.rs +++ b/vdr/src/contracts/mod.rs @@ -1,6 +1,7 @@ pub mod anoncreds; pub mod auth; pub mod did; +pub mod endorsing; pub mod migration; pub mod network; diff --git a/vdr/src/contracts/network/validator_control.rs b/vdr/src/contracts/network/validator_control.rs index e82bd34f..275c0865 100644 --- a/vdr/src/contracts/network/validator_control.rs +++ b/vdr/src/contracts/network/validator_control.rs @@ -16,9 +16,9 @@ const METHOD_GET_VALIDATORS: &str = "getValidators"; /// Build transaction to execute ValidatorControl.addValidator contract method to add a new Validator /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address -/// - `validator_address` validator address to be added +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `from`: [Address] - transaction sender account address +/// - `validator_address`: [Address] - validator address to be added /// /// # Returns /// Write transaction to sign and submit @@ -42,9 +42,9 @@ pub async fn build_add_validator_transaction( /// Build transaction to execute ValidatorControl.removeValidator contract method to remove an existing Validator /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `from` transaction sender account address -/// - `validator_address` validator address to be removed +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `from`: [Address] - transaction sender account address +/// - `validator_address`: [Address] - validator address to be removed /// /// # Returns /// Write transaction to sign and submit @@ -68,7 +68,7 @@ pub async fn build_remove_validator_transaction( /// Build transaction to execute ValidatorControl.getValidators contract method to get existing validators /// /// # Params -/// - `client` client connected to the network where contract will be executed +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed /// /// # Returns /// Read transaction to submit @@ -86,8 +86,8 @@ pub async fn build_get_validators_transaction(client: &LedgerClient) -> VdrResul /// Parse the result of execution ValidatorControl.getValidators contract method to get existing validators /// /// # Params -/// - `client` client connected to the network where contract will be executed -/// - `bytes` result bytes returned from the ledger +/// - `client`: [LedgerClient] - client connected to the network where contract will be executed +/// - `bytes`: [Vec] - result bytes returned from the ledger /// /// # Returns /// Parsed validator addresses @@ -108,7 +108,6 @@ pub mod test { use super::*; use crate::client::client::test::{mock_client, CONFIG, DEFAULT_NONCE, TRUSTEE_ACCOUNT}; use once_cell::sync::Lazy; - use std::sync::RwLock; pub static VALIDATOR_ADDRESS: Lazy
= Lazy::new(|| Address::from("0x93917cadbace5dfce132b991732c6cda9bcc5b8a")); @@ -151,7 +150,7 @@ pub mod test { nonce: Some(DEFAULT_NONCE.clone()), chain_id: CONFIG.chain_id, data: expected_data.into(), - signature: RwLock::new(None), + signature: None, hash: None, }; @@ -181,7 +180,7 @@ pub mod test { nonce: Some(DEFAULT_NONCE.clone()), chain_id: CONFIG.chain_id, data: expected_data.into(), - signature: RwLock::new(None), + signature: None, hash: None, }; @@ -205,7 +204,7 @@ pub mod test { nonce: None, chain_id: CONFIG.chain_id, data: encoded_method.into(), - signature: RwLock::new(None), + signature: None, hash: None, }; diff --git a/vdr/src/error/mod.rs b/vdr/src/error/mod.rs index ae687a7d..4af7ed5b 100644 --- a/vdr/src/error/mod.rs +++ b/vdr/src/error/mod.rs @@ -16,6 +16,9 @@ pub enum VdrError { #[error("Ledger Client: Invalid transaction: {}", _0)] ClientInvalidTransaction(String), + #[error("Ledger Client: Invalid endorsement dara: {}", _0)] + ClientInvalidEndorsementData(String), + #[error("Ledger Client: Got invalid response: {}", _0)] ClientInvalidResponse(String), diff --git a/vdr/src/lib.rs b/vdr/src/lib.rs index 7700d9cc..43afd5b5 100644 --- a/vdr/src/lib.rs +++ b/vdr/src/lib.rs @@ -20,8 +20,12 @@ pub use contracts::{ anoncreds::{ credential_definition_registry, schema_registry, types::{ - credential_definition::CredentialDefinition, - credential_definition_id::CredentialDefinitionId, schema::Schema, schema_id::SchemaId, + credential_definition::{ + CredentialDefinition, CredentialDefinitionRecord, SignatureType, + }, + credential_definition_id::CredentialDefinitionId, + schema::{Schema, SchemaRecord}, + schema_id::SchemaId, }, }, auth::{role_control, Role}, @@ -30,8 +34,8 @@ pub use contracts::{ types::{ did::DID, did_doc::{ - DidDocument, DidResolutionOptions, Service, ServiceEndpoint, ServiceEndpointObject, - VerificationKeyType, + DidDocument, DidDocumentWithMeta, DidRecord, DidResolutionOptions, Service, + ServiceEndpoint, ServiceEndpointObject, StringOrVector, VerificationKeyType, }, did_doc_attribute::{ DelegateType, DidDocAttribute, PublicKeyAttribute, PublicKeyPurpose, PublicKeyType, @@ -41,6 +45,7 @@ pub use contracts::{ did_events::{DidAttributeChanged, DidDelegateChanged, DidEvents, DidOwnerChanged}, }, }, + endorsing, migration::{ legacy_mapping_registry, types::{ @@ -50,7 +55,6 @@ pub use contracts::{ }, }, network::validator_control, - StringOrVector, }; pub use error::{VdrError, VdrResult}; pub use types::*; diff --git a/vdr/src/test.rs b/vdr/src/test.rs index 2ff4a214..eeae73fc 100644 --- a/vdr/src/test.rs +++ b/vdr/src/test.rs @@ -9,16 +9,16 @@ use crate::{ }, signer::basic_signer::{test::basic_signer, BasicSigner}, types::{Address, SignatureData, Transaction}, - LedgerClient, TransactionEndorsingData, + LedgerClient, }; mod helpers { use super::*; - use crate::{Address, LedgerClient}; + use crate::{contracts::endorsing, Address, LedgerClient, TransactionEndorsingData}; pub async fn sign_and_submit_transaction( client: &LedgerClient, - transaction: Transaction, + mut transaction: Transaction, signer: &BasicSigner, ) -> String { let sign_bytes = transaction.get_signing_bytes().unwrap(); @@ -38,6 +38,24 @@ mod helpers { .unwrap() } + pub async fn endorse_transaction( + client: &LedgerClient, + signer: &BasicSigner, + mut data: TransactionEndorsingData, + ) { + let signature = signer + .sign(&data.get_signing_bytes().unwrap(), data.from.as_ref()) + .unwrap(); + + data.set_signature(signature); + + let transaction = endorsing::build_endorsement_transaction(client, &TRUSTEE_ACCOUNT, &data) + .await + .unwrap(); + + super::helpers::sign_and_submit_transaction(&client, transaction, &signer).await; + } + pub async fn assign_role( client: &LedgerClient, assignee_account: &Address, @@ -64,7 +82,7 @@ mod helpers { mod did_indy { use super::*; - use crate::client::client::test::TRUSTEE_ACCOUNT; + use crate::{client::client::test::TRUSTEE_ACCOUNT, contracts::endorsing}; async fn resolve_did(client: &LedgerClient, did: &DID) -> DidRecord { let transaction = did_indy_registry::build_resolve_did_transaction(client, did) @@ -135,22 +153,18 @@ mod did_indy { // create let did_doc = did_doc(identity.as_ref()); - let endorsement_data = + let mut endorsement_data = did_indy_registry::build_create_did_endorsing_data(&client, &did_doc.id, &did_doc) .await .unwrap(); let signature = super::helpers::sign_endorsing_data(&endorsement_data, &signer); + endorsement_data.set_signature(signature); - let transaction = did_indy_registry::build_create_did_signed_transaction( - &client, - &TRUSTEE_ACCOUNT, - &did_doc.id, - &did_doc, - &signature, - ) - .await - .unwrap(); + let transaction = + endorsing::build_endorsement_transaction(&client, &TRUSTEE_ACCOUNT, &endorsement_data) + .await + .unwrap(); super::helpers::sign_and_submit_transaction(&client, transaction, &signer).await; @@ -193,20 +207,7 @@ mod did_ethr { .await .unwrap(); - let signature = super::helpers::sign_endorsing_data(&transaction_endorsing_data, signer); - - let transaction = did_ethr_registry::build_did_set_attribute_signed_transaction( - client, - &TRUSTEE_ACCOUNT, - did, - attribute, - validity, - &signature, - ) - .await - .unwrap(); - - super::helpers::sign_and_submit_transaction(&client, transaction, &signer).await; + super::helpers::endorse_transaction(client, signer, transaction_endorsing_data).await; } async fn endorse_revoke_did_attribute( @@ -214,24 +215,13 @@ mod did_ethr { did: &DID, attribute: &DidDocAttribute, signer: &BasicSigner, - ) -> String { + ) { let transaction_endorsing_data = did_ethr_registry::build_did_revoke_attribute_endorsing_data(client, did, attribute) .await .unwrap(); - let signature = super::helpers::sign_endorsing_data(&transaction_endorsing_data, signer); - - let transaction = did_ethr_registry::build_did_revoke_attribute_signed_transaction( - client, - &TRUSTEE_ACCOUNT, - did, - attribute, - &signature, - ) - .await - .unwrap(); - super::helpers::sign_and_submit_transaction(&client, transaction, &signer).await + super::helpers::endorse_transaction(client, signer, transaction_endorsing_data).await; } #[async_std::test] @@ -345,19 +335,7 @@ mod did_ethr { did_ethr_registry::build_did_change_owner_endorsing_data(&client, &did, &new_owner) .await .unwrap(); - - let signature = super::helpers::sign_endorsing_data(&transaction_endorsing_data, &signer); - - let transaction = did_ethr_registry::build_did_change_owner_signed_transaction( - &client, - &TRUSTEE_ACCOUNT, - &did, - &new_owner, - &signature, - ) - .await - .unwrap(); - super::helpers::sign_and_submit_transaction(&client, transaction, &signer).await; + super::helpers::endorse_transaction(&client, &signer, transaction_endorsing_data).await; // Resole DID document let did_doc_with_meta = did_resolver::resolve_did(&client, &did, None) @@ -452,7 +430,6 @@ mod did_ethr { let did_doc_with_meta = did_resolver::resolve_did(&client, &did, None) .await .unwrap(); - println!("{:?}", did_doc_with_meta); let did_document = did_doc_with_meta.did_document.unwrap(); // DID Document is empty @@ -478,17 +455,8 @@ mod schema { .await .unwrap(); - let signature = super::helpers::sign_endorsing_data(&transaction_endorsing_data, signer); + super::helpers::endorse_transaction(client, signer, transaction_endorsing_data).await; - let transaction = schema_registry::build_create_schema_signed_transaction( - client, - &TRUSTEE_ACCOUNT.clone(), - &schema, - &signature, - ) - .await - .unwrap(); - super::helpers::sign_and_submit_transaction(client, transaction, signer).await; schema } @@ -603,18 +571,7 @@ mod credential_definition { .await .unwrap(); - let signature = super::helpers::sign_endorsing_data(&transaction_endorsing_data, &signer); - - let transaction = - credential_definition_registry::build_create_credential_definition_signed_transaction( - &client, - &TRUSTEE_ACCOUNT.clone(), - &credential_definition, - &signature, - ) - .await - .unwrap(); - super::helpers::sign_and_submit_transaction(&client, transaction, &signer).await; + super::helpers::endorse_transaction(&client, &signer, transaction_endorsing_data).await; // read let resolved_credential_definition = @@ -638,7 +595,7 @@ mod role { role_to_revoke: &Role, signer: &BasicSigner, ) -> String { - let transaction = role_control::build_revoke_role_transaction( + let mut transaction = role_control::build_revoke_role_transaction( client, &TRUSTEE_ACCOUNT, role_to_revoke, @@ -888,21 +845,7 @@ mod mapping { .await .unwrap(); - let signature = super::helpers::sign_endorsing_data(&transaction_endorsing_data, &signer); - - let transaction = legacy_mapping_registry::build_create_did_mapping_signed_transaction( - &client, - &TRUSTEE_ACCOUNT, - &did, - &legacy_did, - &legacy_verkey, - &legacy_signature, - &signature, - ) - .await - .unwrap(); - - super::helpers::sign_and_submit_transaction(&client, transaction, &signer).await; + super::helpers::endorse_transaction(&client, &signer, transaction_endorsing_data).await; // read DID mapping let transaction = @@ -935,22 +878,7 @@ mod mapping { .await .unwrap(); - let signature = super::helpers::sign_endorsing_data(&transaction_endorsing_data, &signer); - - let transaction = - legacy_mapping_registry::build_create_resource_mapping_signed_transaction( - &client, - &TRUSTEE_ACCOUNT, - &did, - &legacy_did, - &legacy_schema_id, - &schema_id, - &signature, - ) - .await - .unwrap(); - - super::helpers::sign_and_submit_transaction(&client, transaction, &signer).await; + super::helpers::endorse_transaction(&client, &signer, transaction_endorsing_data).await; // read schema mapping let transaction = legacy_mapping_registry::build_get_resource_mapping_transaction( diff --git a/vdr/src/types/address.rs b/vdr/src/types/address.rs index 84643110..3835b430 100644 --- a/vdr/src/types/address.rs +++ b/vdr/src/types/address.rs @@ -12,6 +12,7 @@ use std::str::FromStr; const PREFIX: &str = "0x"; const NULL_ADDRESS: &str = "0x0000000000000000000000000000000000000000"; +/// Wrapper structure for Ethereum account address #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct Address(String); diff --git a/vdr/src/types/contract.rs b/vdr/src/types/contract.rs index 8a946d57..e8c7cb72 100644 --- a/vdr/src/types/contract.rs +++ b/vdr/src/types/contract.rs @@ -242,11 +242,11 @@ impl TryFrom<&MethodUintBytesParam> for ContractParam { } #[derive(Debug)] -pub(crate) struct MethodStringParam(&'static str); +pub(crate) struct MethodStringParam(String); -impl From<&'static str> for MethodStringParam { - fn from(value: &'static str) -> Self { - MethodStringParam(value) +impl From<&str> for MethodStringParam { + fn from(value: &str) -> Self { + MethodStringParam(value.to_string()) } } diff --git a/vdr/src/types/endorsing_data.rs b/vdr/src/types/endorsing_data.rs new file mode 100644 index 00000000..991b059a --- /dev/null +++ b/vdr/src/types/endorsing_data.rs @@ -0,0 +1,167 @@ +use ethabi::Uint; +use log_derive::{logfn, logfn_inputs}; +use serde::{Deserialize, Serialize}; +use sha3::Digest; +use std::fmt::Debug; + +use crate::{ + types::{ContractParam, MethodStringParam, MethodUintBytesParam}, + Address, LedgerClient, Nonce, SignatureData, VdrError, VdrResult, +}; + +/// Definition of transaction endorsing data for off-chain author signature +#[derive(Debug, Default, Serialize, Deserialize)] +pub struct TransactionEndorsingData { + pub to: Address, + pub from: Address, + pub nonce: Option, + pub contract: String, + pub method: String, + pub endorsing_method: String, + pub params: Vec, + pub signature: Option, +} + +impl TransactionEndorsingData { + const PREFIX: u8 = 0x19; + const VERSION: u8 = 0x0; + + /// Get transaction bytes which are need to be signed by the author before passing it to sender who will submit transaction on the ledger + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn get_signing_bytes(&self) -> VdrResult> { + let mut tokens = vec![ + ContractParam::Uint(Uint::from(Self::PREFIX)), + ContractParam::FixedBytes(vec![Self::VERSION]), + (&self.to).try_into()?, + ]; + if let Some(ref nonce) = self.nonce { + tokens.push(nonce.try_into()?) + } + tokens.push((&self.from).try_into()?); + tokens.push((&MethodStringParam::from(self.method.as_str())).try_into()?); + for param in self.params.iter() { + match param { + ContractParam::Uint(uint) => { + // uint values represented as bytes on endorsing signature verification + tokens.push((&MethodUintBytesParam::from(uint.as_u64())).try_into()?) + } + _ => tokens.push(param.to_owned()), + }; + } + + let encoded = ethers_core::abi::encode_packed(&tokens).unwrap(); + let hash = sha3::Keccak256::digest(encoded).to_vec(); + Ok(hash) + } + + /// Set author's transaction signature + #[logfn(Info)] + #[logfn_inputs(Debug)] + pub fn set_signature(&mut self, signature_data: SignatureData) { + self.signature = Some(signature_data) + } + + /// Serialize transaction endorsement as JSON string + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn to_string(&self) -> VdrResult { + serde_json::to_string(self).map_err(|err| { + VdrError::ClientInvalidEndorsementData(format!( + "Unable to serialize endorsement data as JSON. Err: {:?}", + err + )) + }) + } + + /// Deserialize transaction endorsement data from JSON string + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn from_string(value: &str) -> VdrResult { + serde_json::from_str(value).map_err(|err| { + VdrError::ClientInvalidEndorsementData(format!( + "Unable to deserialize endorsement data from JSON. Err: {:?}", + err + )) + }) + } +} + +#[derive(Debug, Default)] +pub(crate) struct TransactionEndorsingDataBuilder { + contract: String, + identity: Address, + nonce: Option, + method: String, + endorsing_method: String, + params: Vec, +} + +impl TransactionEndorsingDataBuilder { + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn new() -> TransactionEndorsingDataBuilder { + TransactionEndorsingDataBuilder::default() + } + + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn set_contract(mut self, contract: &str) -> TransactionEndorsingDataBuilder { + self.contract = contract.to_string(); + self + } + + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn set_identity(mut self, identity: &Address) -> TransactionEndorsingDataBuilder { + self.identity = identity.to_owned(); + self + } + + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn set_method(mut self, method: &str) -> TransactionEndorsingDataBuilder { + self.method = method.to_owned(); + self + } + + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn set_endorsing_method(mut self, method: &str) -> TransactionEndorsingDataBuilder { + self.endorsing_method = method.to_owned(); + self + } + + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn set_nonce(mut self, nonce: &Nonce) -> TransactionEndorsingDataBuilder { + self.nonce = Some(nonce.to_owned()); + self + } + + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn add_param + Debug>( + mut self, + param: T, + ) -> VdrResult { + self.params.push(param.try_into()?); + Ok(self) + } + + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub async fn build(self, client: &LedgerClient) -> VdrResult { + let contract = client.contract(&self.contract)?; + Ok(TransactionEndorsingData { + to: contract.address().to_owned(), + from: self.identity.to_owned(), + nonce: self.nonce, + method: self.method, + contract: self.contract, + endorsing_method: self.endorsing_method, + params: self.params, + signature: Default::default(), + }) + } +} diff --git a/vdr/src/types/event_query.rs b/vdr/src/types/event_query.rs index b61787c8..6c828ac8 100644 --- a/vdr/src/types/event_query.rs +++ b/vdr/src/types/event_query.rs @@ -8,6 +8,7 @@ use log_derive::{logfn, logfn_inputs}; use serde_derive::{Deserialize, Serialize}; use std::fmt::Debug; +/// Definition of query object to query logged events from the ledger #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct EventQuery { diff --git a/vdr/src/types/mod.rs b/vdr/src/types/mod.rs index 5eb54453..c0077d38 100644 --- a/vdr/src/types/mod.rs +++ b/vdr/src/types/mod.rs @@ -1,24 +1,20 @@ mod address; mod contract; +mod endorsing_data; mod event_query; mod signature; mod status; pub(crate) mod transaction; pub use address::Address; -pub use contract::{ContractConfig, ContractSpec}; +pub use contract::{ContractConfig, ContractParam, ContractSpec}; +pub use endorsing_data::TransactionEndorsingData; pub use event_query::{EventLog, EventQuery}; pub use signature::SignatureData; pub use status::{PingStatus, Status}; -pub use transaction::{ - Block, BlockDetails, Nonce, Transaction, TransactionEndorsingData, TransactionSignature, - TransactionType, -}; +pub use transaction::{Block, BlockDetails, Nonce, Transaction, TransactionType}; -pub(crate) use contract::{ - ContractEvent, ContractOutput, ContractParam, MethodStringParam, MethodUintBytesParam, -}; +pub(crate) use contract::{ContractEvent, ContractOutput, MethodStringParam, MethodUintBytesParam}; +pub(crate) use endorsing_data::TransactionEndorsingDataBuilder; pub(crate) use event_query::{EventParser, EventQueryBuilder}; -pub(crate) use transaction::{ - TransactionBuilder, TransactionEndorsingDataBuilder, TransactionParser, -}; +pub(crate) use transaction::{TransactionBuilder, TransactionParser}; diff --git a/vdr/src/types/signature.rs b/vdr/src/types/signature.rs index f6830b0c..f3317c24 100644 --- a/vdr/src/types/signature.rs +++ b/vdr/src/types/signature.rs @@ -1,6 +1,7 @@ use crate::{types::ContractParam, VdrError}; use serde_derive::{Deserialize, Serialize}; +/// Definition of recoverable ECDSA signature #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct SignatureData { /// recovery ID using for public key recovery diff --git a/vdr/src/types/status.rs b/vdr/src/types/status.rs index 5df3782c..f1103f14 100644 --- a/vdr/src/types/status.rs +++ b/vdr/src/types/status.rs @@ -1,6 +1,6 @@ use serde_derive::{Deserialize, Serialize}; -/// Ledger status: whether connected node and network are alive +/// Ledger status: whether connected node and network are alive #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct PingStatus { pub status: Status, diff --git a/vdr/src/types/transaction.rs b/vdr/src/types/transaction.rs index fd11b92e..b18c5b9d 100644 --- a/vdr/src/types/transaction.rs +++ b/vdr/src/types/transaction.rs @@ -7,8 +7,7 @@ use ethereum_types::{H160, H256, U256}; use log::warn; use log_derive::{logfn, logfn_inputs}; use serde_derive::{Deserialize, Serialize}; -use sha3::Digest; -use std::{fmt::Debug, str::FromStr, sync::RwLock}; +use std::{fmt::Debug, str::FromStr}; use crate::{ client::{GAS_LIMIT, GAS_PRICE}, @@ -28,8 +27,8 @@ pub enum TransactionType { Write, } -/// Transaction object -#[derive(Debug, Default, Serialize, Deserialize)] +/// Definition of transaction object to send on the ledger +#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize)] pub struct Transaction { /// type of transaction: write/read /// depending on the transaction type different client methods will be executed to submit transaction @@ -48,18 +47,11 @@ pub struct Transaction { /// transaction payload pub data: Vec, /// transaction signature - pub signature: RwLock>, + pub signature: Option, /// transaction hash pub hash: Option>, } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct TransactionSignature { - pub v: u64, - pub r: Vec, - pub s: Vec, -} - impl Transaction { #[logfn(Info)] #[logfn_inputs(Debug)] @@ -70,7 +62,7 @@ impl Transaction { chain_id: u64, data: Vec, nonce: Option, - signature: Option, + signature: Option, ) -> Transaction { Transaction { type_, @@ -79,11 +71,12 @@ impl Transaction { chain_id, data, nonce, - signature: RwLock::new(signature), + signature, hash: None, } } + /// Get transaction bytes which are need to be signed by the sender before the submitting on the ledger #[logfn(Info)] #[logfn_inputs(Debug)] pub fn get_signing_bytes(&self) -> VdrResult> { @@ -100,17 +93,14 @@ impl Transaction { Ok(hash.as_bytes().to_vec()) } + /// Set sender's transaction signature #[logfn(Info)] #[logfn_inputs(Debug)] - pub fn set_signature(&self, signature_data: SignatureData) { - let mut signature = self.signature.write().unwrap(); - *signature = Some(TransactionSignature { - v: signature_data.v().0 + 35 + self.chain_id * 2, - r: signature_data.r().0, - s: signature_data.s().0, - }) + pub fn set_signature(&mut self, signature_data: SignatureData) { + self.signature = Some(signature_data) } + /// Encode transaction as bytes #[logfn(Trace)] #[logfn_inputs(Trace)] pub fn encode(&self) -> VdrResult> { @@ -126,6 +116,30 @@ impl Transaction { Ok(transaction.encode().to_vec()) } + /// Serialize transaction as JSON string + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn to_string(&self) -> VdrResult { + serde_json::to_string(self).map_err(|err| { + VdrError::ClientInvalidTransaction(format!( + "Unable to serialize transaction as JSON. Err: {:?}", + err + )) + }) + } + + /// Deserialize transaction from JSON string + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn from_string(value: &str) -> VdrResult { + serde_json::from_str(value).map_err(|err| { + VdrError::ClientInvalidTransaction(format!( + "Unable to deserialize transaction from JSON. Err: {:?}", + err + )) + }) + } + #[logfn(Trace)] #[logfn_inputs(Trace)] fn get_to(&self) -> VdrResult { @@ -149,54 +163,24 @@ impl Transaction { #[logfn(Trace)] #[logfn_inputs(Trace)] fn get_transaction_signature(&self) -> VdrResult { - let signature = self.signature.read().unwrap(); - let signature = signature + let signature = self + .signature .as_ref() .ok_or_else(|| VdrError::ClientInvalidTransaction("Missing signature".to_string()))? .clone(); let signature = EthTransactionSignature::new( - signature.v, - H256::from_slice(&signature.r), - H256::from_slice(&signature.s), + signature.v().0 + 35 + self.chain_id * 2, // `v` is calculated according to EIP-155: https://eips.ethereum.org/EIPS/eip-155 + H256::from_slice(&signature.r().0), + H256::from_slice(&signature.s().0), ) .ok_or_else(|| { - VdrError::ClientInvalidTransaction("Transaction `nonce` is not set".to_string()) + VdrError::ClientInvalidTransaction("Unable to create transaction signature".to_string()) })?; Ok(signature) } } -impl PartialEq for Transaction { - fn eq(&self, other: &Self) -> bool { - let self_signature = self.signature.read().unwrap(); - let other_signature = other.signature.read().unwrap(); - self.type_ == other.type_ - && self.from == other.from - && self.to == other.to - && self.nonce == other.nonce - && self.chain_id == other.chain_id - && self.data == other.data - && *self_signature == *other_signature - } -} - -#[cfg(test)] -impl Clone for Transaction { - fn clone(&self) -> Self { - Transaction { - type_: self.type_.clone(), - from: self.from.clone(), - to: self.to.clone(), - nonce: self.nonce.clone(), - chain_id: self.chain_id.clone(), - data: self.data.clone(), - signature: RwLock::new(self.signature.read().unwrap().clone()), - hash: self.hash.clone(), - } - } -} - #[derive(Clone, Debug, Default, PartialEq)] pub(crate) struct TransactionBuilder { contract: String, @@ -238,6 +222,16 @@ impl TransactionBuilder { Ok(self) } + #[logfn(Trace)] + #[logfn_inputs(Trace)] + pub fn add_contract_params( + mut self, + params: &[ContractParam], + ) -> VdrResult { + self.params.extend_from_slice(params); + Ok(self) + } + #[logfn(Trace)] #[logfn_inputs(Trace)] pub fn set_type(mut self, type_: TransactionType) -> TransactionBuilder { @@ -291,7 +285,7 @@ impl TransactionBuilder { chain_id: client.chain_id(), data, nonce, - signature: RwLock::new(None), + signature: None, hash: None, }; Ok(transaction) @@ -367,84 +361,7 @@ impl TransactionParser { } } -/// Transaction Endorsing object -#[derive(Debug, Default, Serialize, Deserialize)] -pub struct TransactionEndorsingData { - pub to: Address, - pub from: Address, - pub params: Vec, -} - -impl TransactionEndorsingData { - const PREFIX: u8 = 0x19; - const VERSION: u8 = 0x0; - - #[logfn(Trace)] - #[logfn_inputs(Trace)] - pub fn get_signing_bytes(&self) -> VdrResult> { - let mut tokens = vec![ - ContractParam::Uint(Uint::from(Self::PREFIX)), - ContractParam::FixedBytes(vec![Self::VERSION]), - (&self.to).try_into()?, - ]; - tokens.extend_from_slice(self.params.as_slice()); - - let encoded = ethers_core::abi::encode_packed(&tokens).unwrap(); - let hash = sha3::Keccak256::digest(encoded).to_vec(); - Ok(hash) - } -} - -#[derive(Debug, Default)] -pub(crate) struct TransactionEndorsingDataBuilder { - contract: String, - identity: Address, - params: Vec, -} - -impl TransactionEndorsingDataBuilder { - #[logfn(Trace)] - #[logfn_inputs(Trace)] - pub fn new() -> TransactionEndorsingDataBuilder { - TransactionEndorsingDataBuilder::default() - } - - #[logfn(Trace)] - #[logfn_inputs(Trace)] - pub fn set_contract(mut self, contract: &str) -> TransactionEndorsingDataBuilder { - self.contract = contract.to_string(); - self - } - - #[logfn(Trace)] - #[logfn_inputs(Trace)] - pub fn set_identity(mut self, identity: &Address) -> TransactionEndorsingDataBuilder { - self.identity = identity.to_owned(); - self - } - - #[logfn(Trace)] - #[logfn_inputs(Trace)] - pub fn add_param + Debug>( - mut self, - param: T, - ) -> VdrResult { - self.params.push(param.try_into()?); - Ok(self) - } - - #[logfn(Trace)] - #[logfn_inputs(Trace)] - pub async fn build(self, client: &LedgerClient) -> VdrResult { - let contract = client.contract(&self.contract)?; - Ok(TransactionEndorsingData { - to: contract.address().to_owned(), - from: self.identity.to_owned(), - params: self.params, - }) - } -} - +/// Wrapper structure for transaction block number #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct Block(u64); @@ -478,6 +395,7 @@ impl From<&Block> for ContractParam { } } +/// Wrapper structure for nonce needed for transactions endorsing #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct Nonce(u64); @@ -509,6 +427,7 @@ impl TryFrom<&Nonce> for ContractParam { } } +/// Transaction block details #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct BlockDetails { pub number: u64, @@ -541,7 +460,7 @@ pub mod test { nonce: Some(DEFAULT_NONCE.clone()), chain_id: CONFIG.chain_id, data: vec![], - signature: RwLock::new(None), + signature: None, hash: None, } } @@ -554,7 +473,7 @@ pub mod test { nonce: None, chain_id: CONFIG.chain_id, data: vec![], - signature: RwLock::new(None), + signature: None, hash: None, } } @@ -594,25 +513,7 @@ pub mod test { #[async_std::test] async fn get_transaction_signature_not_set() { let transaction = Transaction { - signature: RwLock::new(None), - ..write_transaction() - }; - - let get_sig_err = transaction.get_transaction_signature().unwrap_err(); - - assert!(matches!( - get_sig_err, | VdrError::ClientInvalidTransaction { .. } - )); - } - - #[async_std::test] - async fn get_transaction_signature_invalid() { - let transaction = Transaction { - signature: RwLock::new(Some(TransactionSignature { - v: 1, - r: vec![1; 32], - s: vec![1; 32], - })), + signature: None, ..write_transaction() }; diff --git a/vdr/uniffi/Cargo.lock b/vdr/uniffi/Cargo.lock index 6e268f72..9657b804 100644 --- a/vdr/uniffi/Cargo.lock +++ b/vdr/uniffi/Cargo.lock @@ -1608,6 +1608,8 @@ dependencies = [ "log", "log-derive", "once_cell", + "rand", + "secp256k1 0.28.2", "serde", "serde_derive", "serde_json", @@ -2576,7 +2578,17 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" dependencies = [ - "secp256k1-sys", + "secp256k1-sys 0.8.1", +] + +[[package]] +name = "secp256k1" +version = "0.28.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" +dependencies = [ + "rand", + "secp256k1-sys 0.9.2", ] [[package]] @@ -2588,6 +2600,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" +dependencies = [ + "cc", +] + [[package]] name = "security-framework" version = "2.9.2" @@ -3479,7 +3500,7 @@ dependencies = [ "pin-project", "reqwest", "rlp", - "secp256k1", + "secp256k1 0.27.0", "serde", "serde_json", "soketto", diff --git a/vdr/uniffi/src/ffi/client.rs b/vdr/uniffi/src/ffi/client.rs index ba76c229..41043898 100644 --- a/vdr/uniffi/src/ffi/client.rs +++ b/vdr/uniffi/src/ffi/client.rs @@ -46,7 +46,7 @@ impl LedgerClient { pub async fn submit_transaction(&self, transaction: &Transaction) -> VdrResult> { self.client - .submit_transaction(&transaction.transaction) + .submit_transaction(&transaction.into()) .await .map_err(VdrError::from) } @@ -54,7 +54,7 @@ impl LedgerClient { pub async fn query_events(&self, query: &EventQuery) -> VdrResult> { Ok(self .client - .query_events(&query.query) + .query_events(&query.into()) .await? .into_iter() .map(EventLog::from) diff --git a/vdr/uniffi/src/ffi/contracts/credential_definition_registry.rs b/vdr/uniffi/src/ffi/contracts/credential_definition_registry.rs index e7829c71..9497ae44 100644 --- a/vdr/uniffi/src/ffi/contracts/credential_definition_registry.rs +++ b/vdr/uniffi/src/ffi/contracts/credential_definition_registry.rs @@ -1,30 +1,33 @@ -use crate::ffi::{ - client::LedgerClient, - error::{VdrError, VdrResult}, - transaction::{Transaction, TransactionEndorsingData}, - types::SignatureData, +use crate::{ + ffi::{ + client::LedgerClient, + endorsing_data::TransactionEndorsingData, + error::{VdrError, VdrResult}, + transaction::Transaction, + }, + JsonValue, +}; + +use indy_besu_vdr::{ + credential_definition_registry, Address, CredentialDefinition as CredentialDefinition_, + CredentialDefinitionId, SchemaId, SignatureType, DID, }; -use indy_besu_vdr::{credential_definition_registry, Address, CredentialDefinitionId}; use serde_json::json; #[uniffi::export(async_runtime = "tokio")] pub async fn build_create_credential_definition_transaction( client: &LedgerClient, from: &str, - credential_definition: &str, + credential_definition: &CredentialDefinition, ) -> VdrResult { - let credential_definition = - serde_json::from_str(credential_definition).map_err(|err| VdrError::CommonInvalidData { - msg: format!("Unable to parse credential definition. Err: {:?}", err), - })?; - let transaction = - credential_definition_registry::build_create_credential_definition_transaction( - &client.client, - &Address::from(from), - &credential_definition, - ) - .await?; - Ok(Transaction { transaction }) + credential_definition_registry::build_create_credential_definition_transaction( + &client.client, + &Address::from(from), + &CredentialDefinition_::from(credential_definition), + ) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export(async_runtime = "tokio")] @@ -46,59 +49,96 @@ pub async fn build_create_credential_definition_endorsing_data( } #[uniffi::export(async_runtime = "tokio")] -pub async fn build_create_credential_definition_signed_transaction( +pub async fn build_resolve_credential_definition_transaction( client: &LedgerClient, - from: &str, - credential_definition: &str, - signature: SignatureData, + id: &str, ) -> VdrResult { - let credential_definition = - serde_json::from_str(credential_definition).map_err(|err| VdrError::CommonInvalidData { - msg: format!("Unable to parse credential definition. Err: {:?}", err), - })?; - credential_definition_registry::build_create_credential_definition_signed_transaction( + credential_definition_registry::build_resolve_credential_definition_transaction( &client.client, - &Address::from(from), - &credential_definition, - &signature.into(), + &CredentialDefinitionId::from(id), ) .await .map(Transaction::from) .map_err(VdrError::from) } -#[uniffi::export(async_runtime = "tokio")] -pub async fn build_resolve_credential_definition_transaction( - client: &LedgerClient, - id: &str, -) -> VdrResult { - let transaction = - credential_definition_registry::build_resolve_credential_definition_transaction( - &client.client, - &CredentialDefinitionId::from(id), - ) - .await?; - Ok(Transaction { transaction }) -} - #[uniffi::export] pub fn parse_resolve_credential_definition_result( client: &LedgerClient, bytes: Vec, -) -> VdrResult { +) -> VdrResult { let cred_def = credential_definition_registry::parse_resolve_credential_definition_result( &client.client, &bytes, )?; - Ok(json!(cred_def).to_string()) + Ok(json!(cred_def)) } #[uniffi::export(async_runtime = "tokio")] -pub async fn resolve_credential_definition(client: &LedgerClient, id: &str) -> VdrResult { - let schema = credential_definition_registry::resolve_credential_definition( +pub async fn resolve_credential_definition( + client: &LedgerClient, + id: &str, +) -> VdrResult { + credential_definition_registry::resolve_credential_definition( &client.client, &CredentialDefinitionId::from(id), ) - .await?; - Ok(json!(schema).to_string()) + .await + .map(CredentialDefinition::from) + .map_err(VdrError::from) +} + +#[derive(uniffi::Record)] +pub struct CredentialDefinition { + pub issuer_id: String, + pub schema_id: String, + pub cred_def_type: String, + pub tag: String, + pub value: JsonValue, +} + +impl From for CredentialDefinition { + fn from(cred_def: CredentialDefinition_) -> Self { + CredentialDefinition { + issuer_id: cred_def.issuer_id.as_ref().to_string(), + schema_id: cred_def.schema_id.as_ref().to_string(), + cred_def_type: cred_def.cred_def_type.to_str().to_string(), + tag: cred_def.tag.to_string(), + value: cred_def.value, + } + } +} + +impl From<&CredentialDefinition> for CredentialDefinition_ { + fn from(cred_def: &CredentialDefinition) -> Self { + CredentialDefinition_ { + issuer_id: DID::from(cred_def.issuer_id.as_str()), + schema_id: SchemaId::from(cred_def.schema_id.as_ref()), + cred_def_type: SignatureType::CL, + tag: cred_def.tag.to_string(), + value: cred_def.value.clone(), + } + } +} + +#[uniffi::export] +pub fn credential_definition_get_id(cred_def: &CredentialDefinition) -> String { + CredentialDefinition_::from(cred_def) + .id() + .as_ref() + .to_string() +} + +#[uniffi::export] +pub fn credential_definition_to_string(data: &CredentialDefinition) -> VdrResult { + CredentialDefinition_::from(data) + .to_string() + .map_err(VdrError::from) +} + +#[uniffi::export] +pub fn credential_definition_from_string(string: &str) -> VdrResult { + CredentialDefinition_::from_string(string) + .map(CredentialDefinition::from) + .map_err(VdrError::from) } diff --git a/vdr/uniffi/src/ffi/contracts/did_ethr_registry.rs b/vdr/uniffi/src/ffi/contracts/did_ethr_registry.rs index 8c5bfff5..2699f74c 100644 --- a/vdr/uniffi/src/ffi/contracts/did_ethr_registry.rs +++ b/vdr/uniffi/src/ffi/contracts/did_ethr_registry.rs @@ -1,9 +1,9 @@ use crate::{ ffi::{ client::LedgerClient, + endorsing_data::TransactionEndorsingData, error::{VdrError, VdrResult}, - transaction::{Transaction, TransactionEndorsingData}, - types::SignatureData, + transaction::Transaction, }, EventLog, EventQuery, }; @@ -47,26 +47,6 @@ pub async fn build_did_change_owner_endorsing_data( .map_err(VdrError::from) } -#[uniffi::export(async_runtime = "tokio")] -pub async fn build_did_change_owner_signed_transaction( - client: &LedgerClient, - from: &str, - did: &str, - new_owner: &str, - signature: SignatureData, -) -> VdrResult { - did_ethr_registry::build_did_change_owner_signed_transaction( - &client.client, - &Address::from(from), - &DID::from(did), - &Address::from(new_owner), - &signature.into(), - ) - .await - .map(Transaction::from) - .map_err(VdrError::from) -} - #[uniffi::export(async_runtime = "tokio")] pub async fn build_did_add_delegate_transaction( client: &LedgerClient, @@ -109,30 +89,6 @@ pub async fn build_did_add_delegate_endorsing_data( .map_err(VdrError::from) } -#[uniffi::export(async_runtime = "tokio")] -pub async fn build_did_add_delegate_signed_transaction( - client: &LedgerClient, - from: &str, - did: &str, - delegate_type: &str, - delegate: &str, - validity: u64, - signature: SignatureData, -) -> VdrResult { - did_ethr_registry::build_did_add_delegate_signed_transaction( - &client.client, - &Address::from(from), - &DID::from(did), - &DelegateType::try_from(delegate_type)?, - &Address::from(delegate), - &Validity::from(validity), - &signature.into(), - ) - .await - .map(Transaction::from) - .map_err(VdrError::from) -} - #[uniffi::export(async_runtime = "tokio")] pub async fn build_did_revoke_delegate_transaction( client: &LedgerClient, @@ -171,28 +127,6 @@ pub async fn build_did_revoke_delegate_endorsing_data( .map_err(VdrError::from) } -#[uniffi::export(async_runtime = "tokio")] -pub async fn build_did_revoke_delegate_signed_transaction( - client: &LedgerClient, - from: &str, - did: &str, - delegate_type: &str, - delegate: &str, - signature: SignatureData, -) -> VdrResult { - did_ethr_registry::build_did_revoke_delegate_signed_transaction( - &client.client, - &Address::from(from), - &DID::from(did), - &DelegateType::try_from(delegate_type)?, - &Address::from(delegate), - &signature.into(), - ) - .await - .map(Transaction::from) - .map_err(VdrError::from) -} - #[uniffi::export(async_runtime = "tokio")] pub async fn build_did_set_attribute_transaction( client: &LedgerClient, @@ -241,33 +175,6 @@ pub async fn build_did_set_attribute_endorsing_data( .map_err(VdrError::from) } -#[uniffi::export(async_runtime = "tokio")] -pub async fn build_did_set_attribute_signed_transaction( - client: &LedgerClient, - from: &str, - did: &str, - attribute: &str, - validity: u64, - signature: SignatureData, -) -> VdrResult { - let attribute: DidDocAttribute = - serde_json::from_str(attribute).map_err(|err| VdrError::CommonInvalidData { - msg: format!("Unable to parse DID Attribute. Err: {:?}", err), - })?; - - did_ethr_registry::build_did_set_attribute_signed_transaction( - &client.client, - &Address::from(from), - &DID::from(did), - &attribute, - &Validity::from(validity), - &signature.into(), - ) - .await - .map(Transaction::from) - .map_err(VdrError::from) -} - #[uniffi::export(async_runtime = "tokio")] pub async fn build_did_revoke_attribute_transaction( client: &LedgerClient, @@ -312,31 +219,6 @@ pub async fn build_did_revoke_attribute_endorsing_data( .map_err(VdrError::from) } -#[uniffi::export(async_runtime = "tokio")] -pub async fn build_did_revoke_attribute_signed_transaction( - client: &LedgerClient, - from: &str, - did: &str, - attribute: &str, - signature: SignatureData, -) -> VdrResult { - let attribute: DidDocAttribute = - serde_json::from_str(attribute).map_err(|err| VdrError::CommonInvalidData { - msg: format!("Unable to parse DID Attribute. Err: {:?}", err), - })?; - - did_ethr_registry::build_did_revoke_attribute_signed_transaction( - &client.client, - &Address::from(from), - &DID::from(did), - &attribute, - &signature.into(), - ) - .await - .map(Transaction::from) - .map_err(VdrError::from) -} - #[uniffi::export(async_runtime = "tokio")] pub async fn build_get_did_owner_transaction( client: &LedgerClient, diff --git a/vdr/uniffi/src/ffi/contracts/did_indy_registry.rs b/vdr/uniffi/src/ffi/contracts/did_indy_registry.rs index ecfa9ff4..c461b1ff 100644 --- a/vdr/uniffi/src/ffi/contracts/did_indy_registry.rs +++ b/vdr/uniffi/src/ffi/contracts/did_indy_registry.rs @@ -1,9 +1,13 @@ -use crate::ffi::{ - client::LedgerClient, - error::{VdrError, VdrResult}, - transaction::{Transaction, TransactionEndorsingData}, - types::SignatureData, +use crate::{ + ffi::{ + client::LedgerClient, + error::{VdrError, VdrResult}, + transaction::Transaction, + }, + JsonValue, }; + +use crate::ffi::endorsing_data::TransactionEndorsingData; use indy_besu_vdr::{did_indy_registry, Address, DID}; use serde_json::json; @@ -12,19 +16,20 @@ pub async fn build_create_did_transaction( client: &LedgerClient, from: &str, did: &str, - did_doc: &str, + did_doc: JsonValue, ) -> VdrResult { - let did_doc = serde_json::from_str(did_doc).map_err(|err| VdrError::CommonInvalidData { + let did_doc = serde_json::from_value(did_doc).map_err(|err| VdrError::CommonInvalidData { msg: format!("Unable to parse DID DDocument. Err: {:?}", err), })?; - let transaction = did_indy_registry::build_create_did_transaction( + did_indy_registry::build_create_did_transaction( &client.client, &Address::from(from), &DID::from(did), &did_doc, ) - .await?; - Ok(Transaction { transaction }) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export(async_runtime = "tokio")] @@ -43,48 +48,26 @@ pub async fn build_create_did_endorsing_data( } #[uniffi::export(async_runtime = "tokio")] -pub async fn build_create_did_signed_transaction( +pub async fn build_update_did_transaction( client: &LedgerClient, from: &str, did: &str, did_doc: &str, - signature: SignatureData, ) -> VdrResult { let did_doc = serde_json::from_str(did_doc).map_err(|err| VdrError::CommonInvalidData { - msg: format!("Unable to parse DID Document. Err: {:?}", err), + msg: format!("Unable to parse DID DDocument. Err: {:?}", err), })?; - did_indy_registry::build_create_did_signed_transaction( + did_indy_registry::build_update_did_transaction( &client.client, &Address::from(from), &DID::from(did), &did_doc, - &signature.into(), ) .await .map(Transaction::from) .map_err(VdrError::from) } -#[uniffi::export(async_runtime = "tokio")] -pub async fn build_update_did_transaction( - client: &LedgerClient, - from: &str, - did: &str, - did_doc: &str, -) -> VdrResult { - let did_doc = serde_json::from_str(did_doc).map_err(|err| VdrError::CommonInvalidData { - msg: format!("Unable to parse DID DDocument. Err: {:?}", err), - })?; - let transaction = did_indy_registry::build_update_did_transaction( - &client.client, - &Address::from(from), - &DID::from(did), - &did_doc, - ) - .await?; - Ok(Transaction { transaction }) -} - #[uniffi::export(async_runtime = "tokio")] pub async fn build_update_did_endorsing_data( client: &LedgerClient, @@ -101,43 +84,21 @@ pub async fn build_update_did_endorsing_data( } #[uniffi::export(async_runtime = "tokio")] -pub async fn build_update_did_signed_transaction( +pub async fn build_deactivate_did_transaction( client: &LedgerClient, from: &str, did: &str, - did_doc: &str, - signature: SignatureData, ) -> VdrResult { - let did_doc = serde_json::from_str(did_doc).map_err(|err| VdrError::CommonInvalidData { - msg: format!("Unable to parse DID Document. Err: {:?}", err), - })?; - did_indy_registry::build_update_did_signed_transaction( + did_indy_registry::build_deactivate_did_transaction( &client.client, &Address::from(from), &DID::from(did), - &did_doc, - &signature.into(), ) .await .map(Transaction::from) .map_err(VdrError::from) } -#[uniffi::export(async_runtime = "tokio")] -pub async fn build_deactivate_did_transaction( - client: &LedgerClient, - from: &str, - did: &str, -) -> VdrResult { - let transaction = did_indy_registry::build_deactivate_did_transaction( - &client.client, - &Address::from(from), - &DID::from(did), - ) - .await?; - Ok(Transaction { transaction }) -} - #[uniffi::export(async_runtime = "tokio")] pub async fn build_deactivate_did_endorsing_data( client: &LedgerClient, @@ -149,36 +110,19 @@ pub async fn build_deactivate_did_endorsing_data( .map_err(VdrError::from) } -#[uniffi::export(async_runtime = "tokio")] -pub async fn build_deactivate_did_signed_transaction( - client: &LedgerClient, - from: &str, - did: &str, - signature: SignatureData, -) -> VdrResult { - did_indy_registry::build_deactivate_did_signed_transaction( - &client.client, - &Address::from(from), - &DID::from(did), - &signature.into(), - ) - .await - .map(Transaction::from) - .map_err(VdrError::from) -} - #[uniffi::export(async_runtime = "tokio")] pub async fn build_resolve_did_transaction( client: &LedgerClient, did: &str, ) -> VdrResult { - let transaction = - did_indy_registry::build_resolve_did_transaction(&client.client, &DID::from(did)).await?; - Ok(Transaction { transaction }) + did_indy_registry::build_resolve_did_transaction(&client.client, &DID::from(did)) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export] -pub fn parse_resolve_did_result(client: &LedgerClient, bytes: Vec) -> VdrResult { +pub fn parse_resolve_did_result(client: &LedgerClient, bytes: Vec) -> VdrResult { let did_record = did_indy_registry::parse_resolve_did_result(&client.client, &bytes)?; - Ok(json!(did_record).to_string()) + Ok(json!(did_record)) } diff --git a/vdr/uniffi/src/ffi/contracts/did_resolver.rs b/vdr/uniffi/src/ffi/contracts/did_resolver.rs index e56d95f8..0d2d150d 100644 --- a/vdr/uniffi/src/ffi/contracts/did_resolver.rs +++ b/vdr/uniffi/src/ffi/contracts/did_resolver.rs @@ -1,4 +1,4 @@ -use crate::{LedgerClient, VdrError, VdrResult}; +use crate::{JsonValue, LedgerClient, VdrError, VdrResult}; use serde_json::json; use indy_besu_vdr::{did_resolver, Block, DidResolutionOptions as DidResolutionOptions_, DID}; @@ -8,14 +8,14 @@ pub async fn resolve_did( client: &LedgerClient, did: &str, options: Option, -) -> VdrResult { +) -> VdrResult { let options = match options { Some(options) => Some(DidResolutionOptions_::try_from(options)?), None => None, }; let did_with_meta = did_resolver::resolve_did(&client.client, &DID::from(did), options.as_ref()).await?; - Ok(json!(did_with_meta).to_string()) + Ok(json!(did_with_meta)) } #[derive(uniffi::Record)] diff --git a/vdr/uniffi/src/ffi/contracts/endorsing.rs b/vdr/uniffi/src/ffi/contracts/endorsing.rs new file mode 100644 index 00000000..16961b87 --- /dev/null +++ b/vdr/uniffi/src/ffi/contracts/endorsing.rs @@ -0,0 +1,23 @@ +use crate::ffi::{ + client::LedgerClient, + endorsing_data::TransactionEndorsingData, + error::{VdrError, VdrResult}, + transaction::Transaction, +}; +use indy_besu_vdr::{endorsing, Address}; + +#[uniffi::export(async_runtime = "tokio")] +pub async fn build_endorsement_transaction( + client: &LedgerClient, + from: &str, + endorsing_data: &TransactionEndorsingData, +) -> VdrResult { + endorsing::build_endorsement_transaction( + &client.client, + &Address::from(from), + &endorsing_data.into(), + ) + .await + .map(Transaction::from) + .map_err(VdrError::from) +} diff --git a/vdr/uniffi/src/ffi/contracts/legacy_mapping_registry.rs b/vdr/uniffi/src/ffi/contracts/legacy_mapping_registry.rs index a44eef78..d6c7d58c 100644 --- a/vdr/uniffi/src/ffi/contracts/legacy_mapping_registry.rs +++ b/vdr/uniffi/src/ffi/contracts/legacy_mapping_registry.rs @@ -1,8 +1,8 @@ use crate::ffi::{ client::LedgerClient, + endorsing_data::TransactionEndorsingData, error::{VdrError, VdrResult}, - transaction::{Transaction, TransactionEndorsingData}, - types::SignatureData, + transaction::Transaction, }; use indy_besu_vdr::{ legacy_mapping_registry, Address, Ed25519Signature, LegacyDid, LegacyVerkey, @@ -18,7 +18,7 @@ pub async fn build_create_did_mapping_transaction( legacy_verkey: &str, ed25519_signature: &[u8], ) -> VdrResult { - let transaction = legacy_mapping_registry::build_create_did_mapping_transaction( + legacy_mapping_registry::build_create_did_mapping_transaction( &client.client, &Address::from(from), &DID::from(did), @@ -26,8 +26,9 @@ pub async fn build_create_did_mapping_transaction( &LegacyVerkey::from(legacy_verkey), &Ed25519Signature::from(ed25519_signature), ) - .await?; - Ok(Transaction { transaction }) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export(async_runtime = "tokio")] @@ -50,30 +51,6 @@ pub async fn build_create_did_mapping_endorsing_data( .map_err(VdrError::from) } -#[uniffi::export(async_runtime = "tokio")] -pub async fn build_create_did_mapping_signed_transaction( - client: &LedgerClient, - from: &str, - did: &str, - legacy_identifier: &str, - legacy_verkey: &str, - ed25519_signature: &[u8], - signature: SignatureData, -) -> VdrResult { - legacy_mapping_registry::build_create_did_mapping_signed_transaction( - &client.client, - &Address::from(from), - &DID::from(did), - &LegacyDid::from(legacy_identifier), - &LegacyVerkey::from(legacy_verkey), - &Ed25519Signature::from(ed25519_signature), - &signature.into(), - ) - .await - .map(Transaction::from) - .map_err(VdrError::from) -} - #[uniffi::export(async_runtime = "tokio")] pub async fn build_get_did_mapping_transaction( client: &LedgerClient, @@ -103,7 +80,7 @@ pub async fn build_create_resource_mapping_transaction( legacy_identifier: &str, new_identifier: &str, ) -> VdrResult { - let transaction = legacy_mapping_registry::build_create_resource_mapping_transaction( + legacy_mapping_registry::build_create_resource_mapping_transaction( &client.client, &Address::from(from), &DID::from(did), @@ -111,8 +88,9 @@ pub async fn build_create_resource_mapping_transaction( &ResourceIdentifier::from(legacy_identifier), &ResourceIdentifier::from(new_identifier), ) - .await?; - Ok(Transaction { transaction }) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export(async_runtime = "tokio")] @@ -135,30 +113,6 @@ pub async fn build_create_resource_mapping_endorsing_data( .map_err(VdrError::from) } -#[uniffi::export(async_runtime = "tokio")] -pub async fn build_create_resource_mapping_signed_transaction( - client: &LedgerClient, - from: &str, - did: &str, - legacy_issuer_identifier: &str, - legacy_identifier: &str, - new_identifier: &str, - signature: SignatureData, -) -> VdrResult { - legacy_mapping_registry::build_create_resource_mapping_signed_transaction( - &client.client, - &Address::from(from), - &DID::from(did), - &LegacyDid::from(legacy_issuer_identifier), - &ResourceIdentifier::from(legacy_identifier), - &ResourceIdentifier::from(new_identifier), - &signature.into(), - ) - .await - .map(Transaction::from) - .map_err(VdrError::from) -} - #[uniffi::export(async_runtime = "tokio")] pub async fn build_get_resource_mapping_transaction( client: &LedgerClient, diff --git a/vdr/uniffi/src/ffi/contracts/mod.rs b/vdr/uniffi/src/ffi/contracts/mod.rs index 7de90861..cbaf14f4 100644 --- a/vdr/uniffi/src/ffi/contracts/mod.rs +++ b/vdr/uniffi/src/ffi/contracts/mod.rs @@ -2,6 +2,7 @@ pub mod credential_definition_registry; pub mod did_ethr_registry; pub mod did_indy_registry; pub mod did_resolver; +pub mod endorsing; pub mod legacy_mapping_registry; pub mod role_control; pub mod schema_registry; diff --git a/vdr/uniffi/src/ffi/contracts/role_control.rs b/vdr/uniffi/src/ffi/contracts/role_control.rs index 970548b9..78eb5470 100644 --- a/vdr/uniffi/src/ffi/contracts/role_control.rs +++ b/vdr/uniffi/src/ffi/contracts/role_control.rs @@ -12,14 +12,15 @@ pub async fn build_assign_role_transaction( role: u8, account: &str, ) -> VdrResult { - let transaction = role_control::build_assign_role_transaction( + role_control::build_assign_role_transaction( &client.client, &Address::from(from), &Role::try_from(role)?, &Address::from(account), ) - .await?; - Ok(Transaction { transaction }) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export(async_runtime = "tokio")] @@ -29,14 +30,15 @@ pub async fn build_revoke_role_transaction( role: u8, account: &str, ) -> VdrResult { - let transaction = role_control::build_revoke_role_transaction( + role_control::build_revoke_role_transaction( &client.client, &Address::from(from), &Role::try_from(role)?, &Address::from(account), ) - .await?; - Ok(Transaction { transaction }) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export(async_runtime = "tokio")] @@ -45,13 +47,14 @@ pub async fn build_has_role_transaction( role: u8, account: &str, ) -> VdrResult { - let transaction = role_control::build_has_role_transaction( + role_control::build_has_role_transaction( &client.client, &Role::try_from(role)?, &Address::from(account), ) - .await?; - Ok(Transaction { transaction }) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export(async_runtime = "tokio")] @@ -59,9 +62,10 @@ pub async fn build_get_role_transaction( client: &LedgerClient, account: &str, ) -> VdrResult { - let transaction = - role_control::build_get_role_transaction(&client.client, &Address::from(account)).await?; - Ok(Transaction { transaction }) + role_control::build_get_role_transaction(&client.client, &Address::from(account)) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export] diff --git a/vdr/uniffi/src/ffi/contracts/schema_registry.rs b/vdr/uniffi/src/ffi/contracts/schema_registry.rs index c479611f..c1e7a1a8 100644 --- a/vdr/uniffi/src/ffi/contracts/schema_registry.rs +++ b/vdr/uniffi/src/ffi/contracts/schema_registry.rs @@ -1,11 +1,15 @@ -use crate::ffi::{ - client::LedgerClient, - error::{VdrError, VdrResult}, - transaction::{Transaction, TransactionEndorsingData}, - types::SignatureData, +use crate::{ + ffi::{ + client::LedgerClient, + endorsing_data::TransactionEndorsingData, + error::{VdrError, VdrResult}, + transaction::Transaction, + }, + JsonValue, }; -use indy_besu_vdr::{schema_registry, Address, SchemaId}; +use indy_besu_vdr::{schema_registry, Address, Schema as Schema_, SchemaId, DID}; use serde_json::json; +use std::collections::HashSet; #[uniffi::export(async_runtime = "tokio")] pub async fn build_create_schema_transaction( @@ -16,69 +20,91 @@ pub async fn build_create_schema_transaction( let schema = serde_json::from_str(schema).map_err(|err| VdrError::CommonInvalidData { msg: format!("Unable to parse credential definition. Err: {:?}", err), })?; - let transaction = schema_registry::build_create_schema_transaction( - &client.client, - &Address::from(from), - &schema, - ) - .await?; - Ok(Transaction { transaction }) + schema_registry::build_create_schema_transaction(&client.client, &Address::from(from), &schema) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export(async_runtime = "tokio")] pub async fn build_create_schema_endorsing_data( client: &LedgerClient, - schema: &str, + schema: &Schema, ) -> VdrResult { - let schema = serde_json::from_str(schema).map_err(|err| VdrError::CommonInvalidData { - msg: format!("Unable to parse credential definition. Err: {:?}", err), - })?; - schema_registry::build_create_schema_endorsing_data(&client.client, &schema) + schema_registry::build_create_schema_endorsing_data(&client.client, &Schema_::from(schema)) .await .map(TransactionEndorsingData::from) .map_err(VdrError::from) } -#[uniffi::export(async_runtime = "tokio")] -pub async fn build_create_schema_signed_transaction( - client: &LedgerClient, - from: &str, - schema: &str, - signature: SignatureData, -) -> VdrResult { - let schema = serde_json::from_str(schema).map_err(|err| VdrError::CommonInvalidData { - msg: format!("Unable to parse credential definition. Err: {:?}", err), - })?; - schema_registry::build_create_schema_signed_transaction( - &client.client, - &Address::from(from), - &schema, - &signature.into(), - ) - .await - .map(Transaction::from) - .map_err(VdrError::from) -} - #[uniffi::export(async_runtime = "tokio")] pub async fn build_resolve_schema_transaction( client: &LedgerClient, id: &str, ) -> VdrResult { - let transaction = - schema_registry::build_resolve_schema_transaction(&client.client, &SchemaId::from(id)) - .await?; - Ok(Transaction { transaction }) + schema_registry::build_resolve_schema_transaction(&client.client, &SchemaId::from(id)) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export] -pub fn parse_resolve_schema_result(client: &LedgerClient, bytes: Vec) -> VdrResult { - let schema = schema_registry::parse_resolve_schema_result(&client.client, &bytes)?; - Ok(json!(schema).to_string()) +pub fn parse_resolve_schema_result(client: &LedgerClient, bytes: Vec) -> VdrResult { + let record = schema_registry::parse_resolve_schema_result(&client.client, &bytes)?; + Ok(json!(record)) } #[uniffi::export(async_runtime = "tokio")] -pub async fn resolve_schema(client: &LedgerClient, id: &str) -> VdrResult { - let schema = schema_registry::resolve_schema(&client.client, &SchemaId::from(id)).await?; - Ok(json!(schema).to_string()) +pub async fn resolve_schema(client: &LedgerClient, id: &str) -> VdrResult { + schema_registry::resolve_schema(&client.client, &SchemaId::from(id)) + .await + .map(Schema::from) + .map_err(VdrError::from) +} + +#[derive(uniffi::Record)] +pub struct Schema { + pub issuer_id: String, + pub name: String, + pub version: String, + pub attr_names: Vec, +} + +impl From for Schema { + fn from(schema: Schema_) -> Self { + Schema { + issuer_id: schema.issuer_id.as_ref().to_string(), + name: schema.name, + version: schema.version, + attr_names: schema.attr_names.iter().cloned().collect(), + } + } +} + +impl From<&Schema> for Schema_ { + fn from(schema: &Schema) -> Self { + Schema_ { + issuer_id: DID::from(schema.issuer_id.as_str()), + name: schema.name.to_string(), + version: schema.version.to_string(), + attr_names: HashSet::from_iter(schema.attr_names.iter().cloned()), + } + } +} + +#[uniffi::export] +pub fn schema_get_id(schema: &Schema) -> String { + Schema_::from(schema).id().as_ref().to_string() +} + +#[uniffi::export] +pub fn schema_to_string(data: &Schema) -> VdrResult { + Schema_::from(data).to_string().map_err(VdrError::from) +} + +#[uniffi::export] +pub fn schema_from_string(string: &str) -> VdrResult { + Schema_::from_string(string) + .map(Schema::from) + .map_err(VdrError::from) } diff --git a/vdr/uniffi/src/ffi/contracts/validator_control.rs b/vdr/uniffi/src/ffi/contracts/validator_control.rs index 9fdab119..7bca2bb3 100644 --- a/vdr/uniffi/src/ffi/contracts/validator_control.rs +++ b/vdr/uniffi/src/ffi/contracts/validator_control.rs @@ -1,4 +1,11 @@ -use crate::ffi::{client::LedgerClient, error::VdrResult, transaction::Transaction}; +use crate::{ + ffi::{ + client::LedgerClient, + error::{VdrError, VdrResult}, + transaction::Transaction, + }, + JsonValue, +}; use indy_besu_vdr::{validator_control, Address}; use serde_json::json; @@ -8,13 +15,14 @@ pub async fn build_add_validator_transaction( from: &str, validator_address: &str, ) -> VdrResult { - let transaction = validator_control::build_add_validator_transaction( + validator_control::build_add_validator_transaction( &client.client, &Address::from(from), &Address::from(validator_address), ) - .await?; - Ok(Transaction { transaction }) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export(async_runtime = "tokio")] @@ -23,23 +31,26 @@ pub async fn build_remove_validator_transaction( from: &str, validator_address: &str, ) -> VdrResult { - let transaction = validator_control::build_remove_validator_transaction( + validator_control::build_remove_validator_transaction( &client.client, &Address::from(from), &Address::from(validator_address), ) - .await?; - Ok(Transaction { transaction }) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export(async_runtime = "tokio")] pub async fn build_get_validators_transaction(client: &LedgerClient) -> VdrResult { - let transaction = validator_control::build_get_validators_transaction(&client.client).await?; - Ok(Transaction { transaction }) + validator_control::build_get_validators_transaction(&client.client) + .await + .map(Transaction::from) + .map_err(VdrError::from) } #[uniffi::export] -pub fn parse_get_validators_result(client: &LedgerClient, bytes: Vec) -> VdrResult { +pub fn parse_get_validators_result(client: &LedgerClient, bytes: Vec) -> VdrResult { let validators = validator_control::parse_get_validators_result(&client.client, &bytes)?; - Ok(json!(validators).to_string()) + Ok(json!(validators)) } diff --git a/vdr/uniffi/src/ffi/endorsing_data.rs b/vdr/uniffi/src/ffi/endorsing_data.rs new file mode 100644 index 00000000..8b5c32a2 --- /dev/null +++ b/vdr/uniffi/src/ffi/endorsing_data.rs @@ -0,0 +1,101 @@ +use crate::{JsonValue, SignatureData, VdrError, VdrResult}; +use indy_besu_vdr::{ + Address, Nonce, SignatureData as SignatureData_, + TransactionEndorsingData as TransactionEndorsingData_, +}; +use serde_json::json; + +#[derive(uniffi::Record)] +pub struct TransactionEndorsingData { + pub to: String, + pub from: String, + pub nonce: Option, + pub contract: String, + pub method: String, + pub endorsing_method: String, + pub params: Vec, + pub signature: Option, +} + +#[uniffi::export] +pub fn transaction_endorsing_data_create( + to: &str, + from: &str, + contract: &str, + method: &str, + endorsing_method: &str, + params: Vec, + nonce: Option, + signature: Option, +) -> TransactionEndorsingData { + TransactionEndorsingData { + to: to.to_string(), + from: from.to_string(), + nonce, + contract: contract.to_string(), + method: method.to_string(), + endorsing_method: endorsing_method.to_string(), + params, + signature, + } +} + +#[uniffi::export] +pub fn transaction_endorsing_data_get_signing_bytes( + data: &TransactionEndorsingData, +) -> VdrResult> { + TransactionEndorsingData_::from(data) + .get_signing_bytes() + .map_err(VdrError::from) +} + +#[uniffi::export] +pub fn transaction_endorsing_data_to_string(data: &TransactionEndorsingData) -> VdrResult { + TransactionEndorsingData_::from(data) + .to_string() + .map_err(VdrError::from) +} + +#[uniffi::export] +pub fn transaction_endorsing_data_from_string(value: &str) -> VdrResult { + TransactionEndorsingData_::from_string(value) + .map(TransactionEndorsingData::from) + .map_err(VdrError::from) +} + +impl From for TransactionEndorsingData { + fn from(data: TransactionEndorsingData_) -> Self { + TransactionEndorsingData { + to: data.to.as_ref().to_string(), + from: data.from.as_ref().to_string(), + nonce: data.nonce.map(|nonce| nonce.value()), + contract: data.contract.to_string(), + method: data.method.to_string(), + endorsing_method: data.endorsing_method.to_string(), + params: data.params.into_iter().map(|param| json!(param)).collect(), + signature: data.signature.as_ref().map(|data| data.into()), + } + } +} + +impl From<&TransactionEndorsingData> for TransactionEndorsingData_ { + fn from(data: &TransactionEndorsingData) -> Self { + TransactionEndorsingData_ { + to: Address::from(data.to.as_ref()), + from: Address::from(data.from.as_ref()), + nonce: data.nonce.map(Nonce::from), + contract: data.contract.to_string(), + method: data.method.to_string(), + endorsing_method: data.endorsing_method.to_string(), + params: data + .params + .iter() + .flat_map(|param| serde_json::from_value(param.to_owned())) + .collect(), + signature: data.signature.as_ref().map(|signature| SignatureData_ { + recovery_id: signature.recovery_id.clone(), + signature: signature.signature.clone(), + }), + } + } +} diff --git a/vdr/uniffi/src/ffi/error.rs b/vdr/uniffi/src/ffi/error.rs index 7f843392..6fdc7a67 100644 --- a/vdr/uniffi/src/ffi/error.rs +++ b/vdr/uniffi/src/ffi/error.rs @@ -8,6 +8,9 @@ pub enum VdrError { #[error("Ledger Client: Invalid transaction: {}", msg)] ClientInvalidTransaction { msg: String }, + #[error("Ledger Client: Invalid endorsement data: {}", msg)] + ClientInvalidEndorsementData { msg: String }, + #[error("Ledger Client: Got invalid response: {}", msg)] ClientInvalidResponse { msg: String }, @@ -67,6 +70,9 @@ impl From for VdrError { match error { VdrError_::ClientNodeUnreachable => VdrError::ClientNodeUnreachable, VdrError_::ClientInvalidTransaction(msg) => VdrError::ClientInvalidTransaction { msg }, + VdrError_::ClientInvalidEndorsementData(msg) => { + VdrError::ClientInvalidEndorsementData { msg } + } VdrError_::ClientInvalidResponse(msg) => VdrError::ClientInvalidResponse { msg }, VdrError_::ClientTransactionReverted(msg) => { VdrError::ClientTransactionReverted { msg } diff --git a/vdr/uniffi/src/ffi/event_query.rs b/vdr/uniffi/src/ffi/event_query.rs index 29d4e542..494fcf7b 100644 --- a/vdr/uniffi/src/ffi/event_query.rs +++ b/vdr/uniffi/src/ffi/event_query.rs @@ -1,35 +1,35 @@ use indy_besu_vdr::{Address, Block, EventLog as EventLog_, EventQuery as EventQuery_}; -#[derive(uniffi::Object)] +#[derive(uniffi::Record)] pub struct EventQuery { - pub query: EventQuery_, + pub address: String, + pub from_block: Option, + pub to_block: Option, + pub event_signature: Option, + pub event_filter: Option, } -#[uniffi::export] -impl EventQuery { - #[uniffi::constructor] - pub fn new( - address: String, - from_block: Option, - to_block: Option, - event_signature: Option, - event_filter: Option, - ) -> EventQuery { - EventQuery { - query: EventQuery_ { - address: Address::from(address.as_str()), - from_block: from_block.map(Block::from), - to_block: to_block.map(Block::from), - event_signature, - event_filter, - }, +impl From<&EventQuery> for EventQuery_ { + fn from(query: &EventQuery) -> Self { + EventQuery_ { + address: Address::from(query.address.as_ref()), + from_block: query.from_block.map(Block::from), + to_block: query.to_block.map(Block::from), + event_signature: query.event_signature.to_owned(), + event_filter: query.event_filter.to_owned(), } } } impl From for EventQuery { fn from(query: EventQuery_) -> Self { - EventQuery { query } + EventQuery { + address: query.address.as_ref().to_string(), + from_block: query.from_block.map(|block| block.value()), + to_block: query.to_block.map(|block| block.value()), + event_signature: query.event_signature, + event_filter: query.event_filter, + } } } diff --git a/vdr/uniffi/src/ffi/mod.rs b/vdr/uniffi/src/ffi/mod.rs index c552bb07..d8ec2462 100644 --- a/vdr/uniffi/src/ffi/mod.rs +++ b/vdr/uniffi/src/ffi/mod.rs @@ -1,5 +1,6 @@ pub mod client; pub mod contracts; +pub mod endorsing_data; pub mod error; pub mod event_query; pub mod transaction; @@ -7,6 +8,7 @@ pub mod types; pub use client::*; pub use contracts::*; +pub use endorsing_data::*; pub use error::*; pub use event_query::*; pub use transaction::*; diff --git a/vdr/uniffi/src/ffi/transaction.rs b/vdr/uniffi/src/ffi/transaction.rs index 1595697e..ca5939b8 100644 --- a/vdr/uniffi/src/ffi/transaction.rs +++ b/vdr/uniffi/src/ffi/transaction.rs @@ -1,70 +1,89 @@ use crate::ffi::{ error::{VdrError, VdrResult}, - types::{SignatureData, TransactionSignature, TransactionType}, -}; -use indy_besu_vdr::{ - Address, Transaction as Transaction_, TransactionEndorsingData as TransactionEndorsingData_, + types::{SignatureData, TransactionType}, }; +use indy_besu_vdr::{Address, Transaction as Transaction_}; -#[derive(uniffi::Object)] +#[derive(uniffi::Record)] pub struct Transaction { - pub transaction: Transaction_, + pub type_: TransactionType, + pub from: Option, + pub to: String, + pub nonce: Option, + pub chain_id: u64, + pub data: Vec, + pub signature: Option, + pub hash: Option>, } -#[uniffi::export] -impl Transaction { - #[uniffi::constructor] - pub fn new( - type_: TransactionType, - from: Option, - to: String, - chain_id: u64, - data: Vec, - nonce: Option, - signature: Option, - ) -> Transaction { +impl From for Transaction { + fn from(transaction: Transaction_) -> Self { Transaction { - transaction: Transaction_::new( - type_.into(), - from.map(|from| Address::from(from.as_str())), - Address::from(to.as_str()), - chain_id, - data, - nonce, - signature.map(TransactionSignature::into), - ), + type_: TransactionType::from(&transaction.type_), + from: transaction.from.map(|from| from.as_ref().to_string()), + to: transaction.to.to_string(), + nonce: transaction.nonce, + chain_id: transaction.chain_id, + data: transaction.data, + signature: transaction.signature.as_ref().map(SignatureData::from), + hash: transaction.hash, } } +} - pub fn get_signing_bytes(&self) -> VdrResult> { - self.transaction.get_signing_bytes().map_err(VdrError::from) - } - - pub fn set_signature(&self, signature_data: SignatureData) { - self.transaction.set_signature(signature_data.into()) +impl From<&Transaction> for Transaction_ { + fn from(transaction: &Transaction) -> Self { + Transaction_ { + type_: (&transaction.type_).into(), + from: transaction.from.as_deref().map(Address::from), + to: Address::from(transaction.to.as_ref()), + nonce: transaction.nonce.clone(), + chain_id: transaction.chain_id, + data: transaction.data.to_owned(), + signature: transaction.signature.as_ref().map(|data| data.into()), + hash: transaction.hash.to_owned(), + } } } -impl From for Transaction { - fn from(transaction: Transaction_) -> Self { - Transaction { transaction } +#[uniffi::export] +pub fn transaction_create( + type_: TransactionType, + to: &str, + from: Option, + nonce: Option, + chain_id: u64, + data: Vec, + signature: Option, + hash: Option>, +) -> Transaction { + Transaction { + type_, + to: to.to_string(), + from: from, + nonce, + chain_id, + data, + signature, + hash, } } -#[derive(uniffi::Object)] -pub struct TransactionEndorsingData { - pub data: TransactionEndorsingData_, +#[uniffi::export] +pub fn transaction_get_signing_bytes(data: &Transaction) -> VdrResult> { + Transaction_::from(data) + .get_signing_bytes() + .map_err(VdrError::from) } #[uniffi::export] -impl TransactionEndorsingData { - pub fn get_signing_bytes(&self) -> VdrResult> { - self.data.get_signing_bytes().map_err(VdrError::from) - } +pub fn transaction_to_string(data: &Transaction) -> VdrResult { + Transaction_::from(data).to_string().map_err(VdrError::from) } -impl From for TransactionEndorsingData { - fn from(data: TransactionEndorsingData_) -> Self { - TransactionEndorsingData { data } - } +#[uniffi::export] +pub fn transaction_from_string(value: &str) -> VdrResult { + Transaction_::from_string(value) + .map(Transaction::from) + .map_err(VdrError::from) } diff --git a/vdr/uniffi/src/ffi/types.rs b/vdr/uniffi/src/ffi/types.rs index 4a61c548..1a31a9cf 100644 --- a/vdr/uniffi/src/ffi/types.rs +++ b/vdr/uniffi/src/ffi/types.rs @@ -2,7 +2,7 @@ use crate::JsonValue; use indy_besu_vdr::{ ContractConfig as ContractConfig_, ContractSpec as ContractSpec_, PingStatus as PingStatus_, QuorumConfig as QuorumConfig_, SignatureData as SignatureData_, Status as Status_, - TransactionSignature as TransactionSignature_, TransactionType as TransactionType_, + TransactionType as TransactionType_, }; #[derive(uniffi::Record)] @@ -46,13 +46,6 @@ pub struct SignatureData { pub signature: Vec, } -#[derive(uniffi::Record)] -pub struct TransactionSignature { - v: u64, - r: Vec, - s: Vec, -} - #[derive(uniffi::Record)] pub struct QuorumConfig { pub nodes: Vec, @@ -103,7 +96,7 @@ impl Into for ContractSpec { } } -impl Into for TransactionType { +impl Into for &TransactionType { fn into(self) -> TransactionType_ { match self { TransactionType::Read => TransactionType_::Read, @@ -112,21 +105,29 @@ impl Into for TransactionType { } } -impl Into for SignatureData { +impl From<&TransactionType_> for TransactionType { + fn from(type_: &TransactionType_) -> TransactionType { + match type_ { + TransactionType_::Read => TransactionType::Read, + TransactionType_::Write => TransactionType::Write, + } + } +} + +impl Into for &SignatureData { fn into(self) -> SignatureData_ { SignatureData_ { - recovery_id: self.recovery_id, - signature: self.signature, + recovery_id: self.recovery_id.to_owned(), + signature: self.signature.to_owned(), } } } -impl Into for TransactionSignature { - fn into(self) -> TransactionSignature_ { - TransactionSignature_ { - v: self.v, - r: self.r, - s: self.s, +impl From<&SignatureData_> for SignatureData { + fn from(signature: &SignatureData_) -> SignatureData { + SignatureData { + recovery_id: signature.recovery_id, + signature: signature.signature.clone(), } } } diff --git a/vdr/wasm/Cargo.toml b/vdr/wasm/Cargo.toml index c497e323..ff51e345 100644 --- a/vdr/wasm/Cargo.toml +++ b/vdr/wasm/Cargo.toml @@ -23,5 +23,6 @@ wasm-bindgen = "0.2.87" wasm-bindgen-futures = "0.4.37" js-sys = "0.3.64" serde-wasm-bindgen = "0.4" +serde_json = "1.0.107" futures = "0.3.28" console_error_panic_hook = "0.1" diff --git a/vdr/wasm/demo/node/src/main.ts b/vdr/wasm/demo/node/src/main.ts index 16dcd502..9bd395c3 100644 --- a/vdr/wasm/demo/node/src/main.ts +++ b/vdr/wasm/demo/node/src/main.ts @@ -3,7 +3,7 @@ import secp256k1 from "secp256k1"; import { readFileSync } from "fs"; import { resolve } from 'path' -import { LedgerClient, EthrDidRegistry, DidResolver, SchemaRegistry } from "indy-besu-vdr"; +import { LedgerClient, EthrDidRegistry, DidResolver, SchemaRegistry, Endorsement, Schema } from "indy-besu-vdr"; const projectRootPath = resolve('../../../..') const trustee = { @@ -55,7 +55,8 @@ async function demo() { const validity = BigInt(1000) let endorsingData = await EthrDidRegistry.buildDidSetAttributeEndorsingData(client, did, serviceAttribute, validity) let authorSignature = sign(endorsingData.getSigningBytes(), identity.secret) - let transaction = await EthrDidRegistry.buildDidSetAttributeSignedTransaction(client, trustee.address, did, serviceAttribute, validity, authorSignature) + endorsingData.setSignature(authorSignature) + let transaction = await Endorsement.buildEndorsementTransaction(client, trustee.address, endorsingData) let transactionSignature = sign(transaction.getSigningBytes(), trustee.secret) transaction.setSignature(transactionSignature) let txnHash = await client.submitTransaction(transaction) @@ -68,16 +69,11 @@ async function demo() { console.log('4. Publish Schema') const name = (Math.random() + 1).toString(36).substring(7) - const schemaId = `${did}/anoncreds/v0/SCHEMA/${name}/1.0.0` - const schema = { - "attrNames": [ "First Name", "Last Name" ], - "issuerId": did, - "name": name, - "version": "1.0.0" - } + let schema = new Schema(did, name, "1.0.0", [ "First Name", "Last Name" ]) let schemaEndorsingData = await SchemaRegistry.buildCreateSchemaEndorsingData(client, schema) authorSignature = sign(schemaEndorsingData.getSigningBytes(), identity.secret) - transaction = await SchemaRegistry.buildCreateSchemaSignedTransaction(client, trustee.address, schema, authorSignature) + schemaEndorsingData.setSignature(authorSignature) + transaction = await Endorsement.buildEndorsementTransaction(client, trustee.address, schemaEndorsingData) transactionSignature = sign(transaction.getSigningBytes(), trustee.secret) transaction.setSignature(transactionSignature) txnHash = await client.submitTransaction(transaction) @@ -85,8 +81,8 @@ async function demo() { console.log(' Schema Transaction receipt: ' + receipt) console.log('5. Resolve Schema') - const resolvedSchema = await SchemaRegistry.resolveSchema(client, schemaId) - console.log(' Resolved Schema: ' + JSON.stringify(resolvedSchema, null, 2)) + const resolvedSchema = await SchemaRegistry.resolveSchema(client, schema.getId()) + console.log(' Resolved Schema: ' + resolvedSchema.toString()) } async function main() { diff --git a/vdr/wasm/src/client.rs b/vdr/wasm/src/client.rs index 03e6c0b7..477c1603 100644 --- a/vdr/wasm/src/client.rs +++ b/vdr/wasm/src/client.rs @@ -54,6 +54,7 @@ impl LedgerClientWrapper { let client = self.0.clone(); let transaction = transaction.0.clone(); future_to_promise(async move { + let transaction = transaction.borrow(); let response = client.submit_transaction(&transaction).await.as_js()?; let result: JsValue = serde_wasm_bindgen::to_value(&response)?; Ok(result) diff --git a/vdr/wasm/src/contracts/credential_definition_registry.rs b/vdr/wasm/src/contracts/credential_definition_registry.rs index ef6de449..8e731cd3 100644 --- a/vdr/wasm/src/contracts/credential_definition_registry.rs +++ b/vdr/wasm/src/contracts/credential_definition_registry.rs @@ -1,6 +1,6 @@ use indy_besu_vdr::{ credential_definition_registry, Address, CredentialDefinition, CredentialDefinitionId, - SignatureData, + SchemaId, SignatureType, DID, }; use std::rc::Rc; use wasm_bindgen::prelude::*; @@ -20,56 +20,34 @@ impl CredentialDefinitionRegistry { pub async fn build_create_credential_definition_transaction( client: &LedgerClientWrapper, from: &str, - cred_def: JsValue, + cred_def: CredentialDefinitionWrapper, ) -> Result { let client = client.0.clone(); - let cred_def: CredentialDefinition = serde_wasm_bindgen::from_value(cred_def)?; let address = Address::from(from); - let transaction = - credential_definition_registry::build_create_credential_definition_transaction( - &client, &address, &cred_def, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + credential_definition_registry::build_create_credential_definition_transaction( + &client, + &address, + &cred_def.0, + ) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildCreateCredentialDefinitionEndorsingData)] pub async fn build_create_credential_definition_endorsing_data( client: &LedgerClientWrapper, - cred_def: JsValue, + cred_def: CredentialDefinitionWrapper, ) -> Result { - let cred_def: CredentialDefinition = serde_wasm_bindgen::from_value(cred_def)?; - let data = - credential_definition_registry::build_create_credential_definition_endorsing_data( - &client.0, &cred_def, - ) - .await - .as_js()?; - Ok(TransactionEndorsingDataWrapper(Rc::new(data))) - } - - #[wasm_bindgen(js_name = buildCreateCredentialDefinitionSignedTransaction)] - pub async fn build_create_credential_definition_signed_transaction( - client: &LedgerClientWrapper, - from: &str, - cred_def: JsValue, - signature_data: JsValue, - ) -> Result { - let client = client.0.clone(); - let cred_def: CredentialDefinition = serde_wasm_bindgen::from_value(cred_def)?; - let address = Address::from(from); - let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - let transaction = - credential_definition_registry::build_create_credential_definition_signed_transaction( - &client, - &address, - &cred_def, - &signature_data, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + credential_definition_registry::build_create_credential_definition_endorsing_data( + &client.0, + &cred_def.0, + ) + .await + .as_js() + .map(TransactionEndorsingDataWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildResolveCredentialDefinitionTransaction)] @@ -78,13 +56,13 @@ impl CredentialDefinitionRegistry { id: &str, ) -> Result { let id = CredentialDefinitionId::from(id); - let transaction = - credential_definition_registry::build_resolve_credential_definition_transaction( - &client.0, &id, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + credential_definition_registry::build_resolve_credential_definition_transaction( + &client.0, &id, + ) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = parseResolveCredentialDefinitionResult)] @@ -104,13 +82,64 @@ impl CredentialDefinitionRegistry { pub async fn resolve_credential_definition( client: &LedgerClientWrapper, id: &str, - ) -> Result { + ) -> Result { let id = CredentialDefinitionId::from(id); - let cred_def = - credential_definition_registry::resolve_credential_definition(&client.0, &id) - .await - .as_js()?; - let result: JsValue = serde_wasm_bindgen::to_value(&cred_def)?; - Ok(result) + credential_definition_registry::resolve_credential_definition(&client.0, &id) + .await + .as_js() + .map(CredentialDefinitionWrapper::from) + .map_err(JsValue::from) + } +} + +#[wasm_bindgen(js_name = CredentialDefinition)] +pub struct CredentialDefinitionWrapper(pub(crate) Rc); + +#[wasm_bindgen(js_class = CredentialDefinition)] +impl CredentialDefinitionWrapper { + #[wasm_bindgen(constructor)] + pub fn new( + issuer_id: String, + schema_id: String, + tag: String, + value: JsValue, + ) -> CredentialDefinitionWrapper { + let value: serde_json::Value = serde_wasm_bindgen::from_value(value).unwrap_or_default(); + CredentialDefinitionWrapper(Rc::new(CredentialDefinition { + issuer_id: DID::from(issuer_id.as_str()), + schema_id: SchemaId::from(schema_id.as_str()), + cred_def_type: SignatureType::CL, + tag, + value, + })) + } + + #[wasm_bindgen(js_name = getId)] + pub fn get_id(&self) -> String { + self.0.id().as_ref().to_string() + } + + #[wasm_bindgen(js_name = toString)] + pub fn to_string(&self) -> Result { + self.0.to_string().as_js().map_err(JsValue::from) + } + + #[wasm_bindgen(js_name = fromString)] + pub fn from_string(string: &str) -> Result { + CredentialDefinition::from_string(string) + .as_js() + .map(CredentialDefinitionWrapper::from) + .map_err(JsValue::from) + } + + #[wasm_bindgen(js_name = asValue)] + pub fn as_value(&self) -> Result { + serde_wasm_bindgen::to_value(&*self.0).map_err(JsValue::from) + } +} + +impl From for CredentialDefinitionWrapper { + fn from(data: CredentialDefinition) -> CredentialDefinitionWrapper { + CredentialDefinitionWrapper(Rc::new(data)) } } diff --git a/vdr/wasm/src/contracts/did_ethr_registry.rs b/vdr/wasm/src/contracts/did_ethr_registry.rs index 4e72a8c3..a61696ad 100644 --- a/vdr/wasm/src/contracts/did_ethr_registry.rs +++ b/vdr/wasm/src/contracts/did_ethr_registry.rs @@ -1,6 +1,5 @@ use indy_besu_vdr::{ - did_ethr_registry, Address, Block, DelegateType, DidDocAttribute, EventLog, SignatureData, - Validity, DID, + did_ethr_registry, Address, Block, DelegateType, DidDocAttribute, EventLog, Validity, DID, }; use std::rc::Rc; use wasm_bindgen::prelude::*; @@ -27,12 +26,11 @@ impl EthrDidRegistry { let sender = Address::from(sender); let did = DID::from(did); let new_owner = Address::from(new_owner); - let transaction = did_ethr_registry::build_did_change_owner_transaction( - &client.0, &sender, &did, &new_owner, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + did_ethr_registry::build_did_change_owner_transaction(&client.0, &sender, &did, &new_owner) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildDidChangeOwnerEndorsingData)] @@ -43,35 +41,11 @@ impl EthrDidRegistry { ) -> Result { let did = DID::from(did); let new_owner = Address::from(new_owner); - let data = - did_ethr_registry::build_did_change_owner_endorsing_data(&client.0, &did, &new_owner) - .await - .as_js()?; - Ok(TransactionEndorsingDataWrapper(Rc::new(data))) - } - - #[wasm_bindgen(js_name = buildDidChangeOwnerSignedTransaction)] - pub async fn build_did_change_owner_signed_transaction( - client: &LedgerClientWrapper, - sender: &str, - did: &str, - new_owner: &str, - signature_data: JsValue, - ) -> Result { - let sender = Address::from(sender); - let did = DID::from(did); - let new_owner = Address::from(new_owner); - let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - let transaction = did_ethr_registry::build_did_change_owner_signed_transaction( - &client.0, - &sender, - &did, - &new_owner, - &signature_data, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + did_ethr_registry::build_did_change_owner_endorsing_data(&client.0, &did, &new_owner) + .await + .as_js() + .map(TransactionEndorsingDataWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildDidAddDelegateTransaction)] @@ -88,7 +62,7 @@ impl EthrDidRegistry { let delegate_type = DelegateType::try_from(delegate_type).as_js()?; let delegate = Address::from(delegate); let validity = Validity::from(validity); - let transaction = did_ethr_registry::build_did_add_delegate_transaction( + did_ethr_registry::build_did_add_delegate_transaction( &client.0, &sender, &did, @@ -97,8 +71,9 @@ impl EthrDidRegistry { &validity, ) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildDidAddDelegateEndorsingData)] @@ -113,46 +88,17 @@ impl EthrDidRegistry { let delegate_type = DelegateType::try_from(delegate_type).as_js()?; let delegate = Address::from(delegate); let validity = Validity::from(validity); - let transaction = did_ethr_registry::build_did_add_delegate_endorsing_data( - &client.0, - &did, - &delegate_type, - &delegate, - &validity, - ) - .await - .as_js()?; - Ok(TransactionEndorsingDataWrapper(Rc::new(transaction))) - } - - #[wasm_bindgen(js_name = buildDidAddDelegateSignedTransaction)] - pub async fn build_did_add_delegate_signed_transaction( - client: &LedgerClientWrapper, - sender: &str, - did: &str, - delegate_type: &str, - delegate: &str, - validity: u64, - signature_data: JsValue, - ) -> Result { - let sender = Address::from(sender); - let did = DID::from(did); - let delegate_type = DelegateType::try_from(delegate_type).as_js()?; - let delegate = Address::from(delegate); - let validity = Validity::from(validity); - let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - let transaction = did_ethr_registry::build_did_add_delegate_signed_transaction( + did_ethr_registry::build_did_add_delegate_endorsing_data( &client.0, - &sender, &did, &delegate_type, &delegate, &validity, - &signature_data, ) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionEndorsingDataWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildDidRevokeDelegateTransaction)] @@ -167,7 +113,7 @@ impl EthrDidRegistry { let did = DID::from(did); let delegate_type = DelegateType::try_from(delegate_type).as_js()?; let delegate = Address::from(delegate); - let transaction = did_ethr_registry::build_did_revoke_delegate_transaction( + did_ethr_registry::build_did_revoke_delegate_transaction( &client.0, &sender, &did, @@ -175,8 +121,9 @@ impl EthrDidRegistry { &delegate, ) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildDidRevokeDelegateEndorsingData)] @@ -189,42 +136,16 @@ impl EthrDidRegistry { let did = DID::from(did); let delegate_type = DelegateType::try_from(delegate_type).as_js()?; let delegate = Address::from(delegate); - let transaction = did_ethr_registry::build_did_revoke_delegate_endorsing_data( - &client.0, - &did, - &delegate_type, - &delegate, - ) - .await - .as_js()?; - Ok(TransactionEndorsingDataWrapper(Rc::new(transaction))) - } - - #[wasm_bindgen(js_name = buildDidRevokeDelegateSignedTransaction)] - pub async fn build_did_revoke_delegate_signed_transaction( - client: &LedgerClientWrapper, - sender: &str, - did: &str, - delegate_type: &str, - delegate: &str, - signature_data: JsValue, - ) -> Result { - let sender = Address::from(sender); - let did = DID::from(did); - let delegate_type = DelegateType::try_from(delegate_type).as_js()?; - let delegate = Address::from(delegate); - let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - let transaction = did_ethr_registry::build_did_revoke_delegate_signed_transaction( + did_ethr_registry::build_did_revoke_delegate_endorsing_data( &client.0, - &sender, &did, &delegate_type, &delegate, - &signature_data, ) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionEndorsingDataWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildDidSetAttributeTransaction)] @@ -239,7 +160,7 @@ impl EthrDidRegistry { let did = DID::from(did); let did_attribute: DidDocAttribute = serde_wasm_bindgen::from_value(attribute)?; let validity = Validity::from(validity); - let transaction = did_ethr_registry::build_did_set_attribute_transaction( + did_ethr_registry::build_did_set_attribute_transaction( &client.0, &sender, &did, @@ -247,8 +168,9 @@ impl EthrDidRegistry { &validity, ) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildDidSetAttributeEndorsingData)] @@ -261,42 +183,16 @@ impl EthrDidRegistry { let did = DID::from(did); let did_attribute: DidDocAttribute = serde_wasm_bindgen::from_value(attribute)?; let validity = Validity::from(validity); - let transaction = did_ethr_registry::build_did_set_attribute_endorsing_data( - &client.0, - &did, - &did_attribute, - &validity, - ) - .await - .as_js()?; - Ok(TransactionEndorsingDataWrapper(Rc::new(transaction))) - } - - #[wasm_bindgen(js_name = buildDidSetAttributeSignedTransaction)] - pub async fn build_did_set_attribute_signed_transaction( - client: &LedgerClientWrapper, - sender: &str, - did: &str, - attribute: JsValue, - validity: u64, - signature_data: JsValue, - ) -> Result { - let sender = Address::from(sender); - let did = DID::from(did); - let did_attribute: DidDocAttribute = serde_wasm_bindgen::from_value(attribute)?; - let validity = Validity::from(validity); - let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - let transaction = did_ethr_registry::build_did_set_attribute_signed_transaction( + did_ethr_registry::build_did_set_attribute_endorsing_data( &client.0, - &sender, &did, &did_attribute, &validity, - &signature_data, ) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionEndorsingDataWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildDidRevokeAttributeTransaction)] @@ -309,15 +205,16 @@ impl EthrDidRegistry { let sender = Address::from(sender); let did = DID::from(did); let did_attribute: DidDocAttribute = serde_wasm_bindgen::from_value(attribute)?; - let transaction = did_ethr_registry::build_did_revoke_attribute_transaction( + did_ethr_registry::build_did_revoke_attribute_transaction( &client.0, &sender, &did, &did_attribute, ) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildDidRevokeAttributeEndorsingData)] @@ -328,38 +225,15 @@ impl EthrDidRegistry { ) -> Result { let did = DID::from(did); let did_attribute: DidDocAttribute = serde_wasm_bindgen::from_value(attribute)?; - let transaction = did_ethr_registry::build_did_revoke_attribute_endorsing_data( - &client.0, - &did, - &did_attribute, - ) - .await - .as_js()?; - Ok(TransactionEndorsingDataWrapper(Rc::new(transaction))) - } - - #[wasm_bindgen(js_name = buildDidRevokeAttributeSignedTransaction)] - pub async fn build_did_revoke_attribute_signed_transaction( - client: &LedgerClientWrapper, - sender: &str, - did: &str, - attribute: JsValue, - signature_data: JsValue, - ) -> Result { - let sender = Address::from(sender); - let did = DID::from(did); - let did_attribute: DidDocAttribute = serde_wasm_bindgen::from_value(attribute)?; - let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - let transaction = did_ethr_registry::build_did_revoke_attribute_signed_transaction( + did_ethr_registry::build_did_revoke_attribute_endorsing_data( &client.0, - &sender, &did, &did_attribute, - &signature_data, ) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionEndorsingDataWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildGetDidOwnerTransaction)] @@ -368,10 +242,11 @@ impl EthrDidRegistry { did: &str, ) -> Result { let did = DID::from(did); - let transaction = did_ethr_registry::build_get_did_owner_transaction(&client.0, &did) + did_ethr_registry::build_get_did_owner_transaction(&client.0, &did) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildGetDidChangedTransaction)] @@ -380,10 +255,11 @@ impl EthrDidRegistry { did: &str, ) -> Result { let did = DID::from(did); - let transaction = did_ethr_registry::build_get_did_changed_transaction(&client.0, &did) + did_ethr_registry::build_get_did_changed_transaction(&client.0, &did) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildGetIdentityNonceTransaction)] @@ -392,11 +268,11 @@ impl EthrDidRegistry { identity: &str, ) -> Result { let identity = Address::from(identity); - let transaction = - did_ethr_registry::build_get_identity_nonce_transaction(&client.0, &identity) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + did_ethr_registry::build_get_identity_nonce_transaction(&client.0, &identity) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildGetDidEventsQuery)] diff --git a/vdr/wasm/src/contracts/did_indy_registry.rs b/vdr/wasm/src/contracts/did_indy_registry.rs index 69f6a279..67009298 100644 --- a/vdr/wasm/src/contracts/did_indy_registry.rs +++ b/vdr/wasm/src/contracts/did_indy_registry.rs @@ -1,5 +1,4 @@ -use indy_besu_vdr::{did_indy_registry, Address, DidDocument, SignatureData, DID}; -use std::rc::Rc; +use indy_besu_vdr::{did_indy_registry, Address, DidDocument, DID}; use wasm_bindgen::prelude::*; use crate::{ @@ -23,11 +22,11 @@ impl IndyDidRegistry { let did_doc: DidDocument = serde_wasm_bindgen::from_value(did_doc)?; let address = Address::from(from); let did = DID::from(did); - let transaction = - did_indy_registry::build_create_did_transaction(&client.0, &address, &did, &did_doc) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + did_indy_registry::build_create_did_transaction(&client.0, &address, &did, &did_doc) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildCreateDidEndorsingData)] @@ -38,34 +37,11 @@ impl IndyDidRegistry { ) -> Result { let did_doc: DidDocument = serde_wasm_bindgen::from_value(did_doc)?; let did = DID::from(did); - let data = did_indy_registry::build_create_did_endorsing_data(&client.0, &did, &did_doc) + did_indy_registry::build_create_did_endorsing_data(&client.0, &did, &did_doc) .await - .as_js()?; - Ok(TransactionEndorsingDataWrapper(Rc::new(data))) - } - - #[wasm_bindgen(js_name = buildCreateDidSignedTransaction)] - pub async fn build_create_did_signed_transaction( - client: &LedgerClientWrapper, - from: &str, - did: &str, - did_doc: JsValue, - signature_data: JsValue, - ) -> Result { - let from = Address::from(from); - let did_doc: DidDocument = serde_wasm_bindgen::from_value(did_doc)?; - let did = DID::from(did); - let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - let transaction = did_indy_registry::build_create_did_signed_transaction( - &client.0, - &from, - &did, - &did_doc, - &signature_data, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionEndorsingDataWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildUpdateDidTransaction)] @@ -78,11 +54,11 @@ impl IndyDidRegistry { let from = Address::from(from); let did = DID::from(did); let did_doc: DidDocument = serde_wasm_bindgen::from_value(did_doc)?; - let transaction = - did_indy_registry::build_update_did_transaction(&client.0, &from, &did, &did_doc) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + did_indy_registry::build_update_did_transaction(&client.0, &from, &did, &did_doc) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildUpdateDidEndorsingData)] @@ -93,34 +69,11 @@ impl IndyDidRegistry { ) -> Result { let did_doc: DidDocument = serde_wasm_bindgen::from_value(did_doc)?; let did = DID::from(did); - let data = did_indy_registry::build_update_did_endorsing_data(&client.0, &did, &did_doc) + did_indy_registry::build_update_did_endorsing_data(&client.0, &did, &did_doc) .await - .as_js()?; - Ok(TransactionEndorsingDataWrapper(Rc::new(data))) - } - - #[wasm_bindgen(js_name = buildUpdateDidSignedTransaction)] - pub async fn build_update_did_signed_transaction( - client: &LedgerClientWrapper, - from: &str, - did: &str, - did_doc: JsValue, - signature_data: JsValue, - ) -> Result { - let from = Address::from(from); - let did_doc: DidDocument = serde_wasm_bindgen::from_value(did_doc)?; - let did = DID::from(did); - let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - let transaction = did_indy_registry::build_update_did_signed_transaction( - &client.0, - &from, - &did, - &did_doc, - &signature_data, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionEndorsingDataWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildDeactivateDidTransaction)] @@ -131,11 +84,11 @@ impl IndyDidRegistry { ) -> Result { let address = Address::from(from); let did = DID::from(did); - let transaction = - did_indy_registry::build_deactivate_did_transaction(&client.0, &address, &did) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + did_indy_registry::build_deactivate_did_transaction(&client.0, &address, &did) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildDeactivateDidEndorsingData)] @@ -144,31 +97,11 @@ impl IndyDidRegistry { did: &str, ) -> Result { let did = DID::from(did); - let data = did_indy_registry::build_deactivate_did_endorsing_data(&client.0, &did) + did_indy_registry::build_deactivate_did_endorsing_data(&client.0, &did) .await - .as_js()?; - Ok(TransactionEndorsingDataWrapper(Rc::new(data))) - } - - #[wasm_bindgen(js_name = buildDeactivateDidSignedTransaction)] - pub async fn build_deactivate_did_signed_transaction( - client: &LedgerClientWrapper, - from: &str, - did: &str, - signature_data: JsValue, - ) -> Result { - let from = Address::from(from); - let did = DID::from(did); - let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - let transaction = did_indy_registry::build_deactivate_did_signed_transaction( - &client.0, - &from, - &did, - &signature_data, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionEndorsingDataWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildResolveDidTransaction)] @@ -177,10 +110,11 @@ impl IndyDidRegistry { did: &str, ) -> Result { let did = DID::from(did); - let transaction = did_indy_registry::build_resolve_did_transaction(&client.0, &did) + did_indy_registry::build_resolve_did_transaction(&client.0, &did) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = parseResolveDidResult)] diff --git a/vdr/wasm/src/contracts/endorsing.rs b/vdr/wasm/src/contracts/endorsing.rs new file mode 100644 index 00000000..d30640db --- /dev/null +++ b/vdr/wasm/src/contracts/endorsing.rs @@ -0,0 +1,28 @@ +use indy_besu_vdr::{endorsing, Address}; +use wasm_bindgen::prelude::*; + +use crate::{ + client::LedgerClientWrapper, + error::{JsResult, Result}, + transaction::{TransactionEndorsingDataWrapper, TransactionWrapper}, +}; + +#[wasm_bindgen(js_name = Endorsement)] +pub struct Endorsement; + +#[wasm_bindgen(js_class = Endorsement)] +impl Endorsement { + #[wasm_bindgen(js_name = buildEndorsementTransaction)] + pub async fn build_endorsement_transaction( + client: &LedgerClientWrapper, + from: &str, + endorsing_data: &TransactionEndorsingDataWrapper, + ) -> Result { + let from = Address::from(from); + endorsing::build_endorsement_transaction(&client.0, &from, &endorsing_data.0.borrow()) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) + } +} diff --git a/vdr/wasm/src/contracts/legacy_mapping_registry.rs b/vdr/wasm/src/contracts/legacy_mapping_registry.rs index 7f397a82..57e8f5d1 100644 --- a/vdr/wasm/src/contracts/legacy_mapping_registry.rs +++ b/vdr/wasm/src/contracts/legacy_mapping_registry.rs @@ -1,8 +1,7 @@ use indy_besu_vdr::{ legacy_mapping_registry, Address, Ed25519Signature, LegacyDid, LegacyVerkey, - ResourceIdentifier, SignatureData, DID, + ResourceIdentifier, DID, }; -use std::rc::Rc; use wasm_bindgen::prelude::*; use crate::{ @@ -30,7 +29,7 @@ impl LegacyMappingRegistry { let legacy_did = LegacyDid::from(legacy_did); let legacy_verkey = LegacyVerkey::from(legacy_verkey); let ed25519_signature = Ed25519Signature::from(ed25519_signature); - let transaction = legacy_mapping_registry::build_create_did_mapping_transaction( + legacy_mapping_registry::build_create_did_mapping_transaction( &client.0, &from, &did, @@ -39,8 +38,9 @@ impl LegacyMappingRegistry { &ed25519_signature, ) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildCreateDidMappingEndorsingData)] @@ -55,7 +55,7 @@ impl LegacyMappingRegistry { let legacy_did = LegacyDid::from(legacy_did); let legacy_verkey = LegacyVerkey::from(legacy_verkey); let ed25519_signature = Ed25519Signature::from(ed25519_signature); - let data = legacy_mapping_registry::build_create_did_mapping_endorsing_data( + legacy_mapping_registry::build_create_did_mapping_endorsing_data( &client.0, &did, &legacy_did, @@ -63,38 +63,9 @@ impl LegacyMappingRegistry { &ed25519_signature, ) .await - .as_js()?; - Ok(TransactionEndorsingDataWrapper(Rc::new(data))) - } - - #[wasm_bindgen(js_name = buildCreateDidMappingSignedTransaction)] - pub async fn build_create_did_mapping_signed_transaction( - client: &LedgerClientWrapper, - from: &str, - did: &str, - legacy_did: &str, - legacy_verkey: &str, - ed25519_signature: &[u8], - signature_data: JsValue, - ) -> Result { - let address = Address::from(from); - let did = DID::from(did); - let legacy_did = LegacyDid::from(legacy_did); - let legacy_verkey = LegacyVerkey::from(legacy_verkey); - let ed25519_signature = Ed25519Signature::from(ed25519_signature); - let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - let transaction = legacy_mapping_registry::build_create_did_mapping_signed_transaction( - &client.0, - &address, - &did, - &legacy_did, - &legacy_verkey, - &ed25519_signature, - &signature_data, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionEndorsingDataWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildGetDidMappingTransaction)] @@ -103,13 +74,11 @@ impl LegacyMappingRegistry { legacy_identifier: &str, ) -> Result { let legacy_identifier = LegacyDid::from(legacy_identifier); - let transaction = legacy_mapping_registry::build_get_did_mapping_transaction( - &client.0, - &legacy_identifier, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + legacy_mapping_registry::build_get_did_mapping_transaction(&client.0, &legacy_identifier) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = parseDidMappingResult)] @@ -135,7 +104,7 @@ impl LegacyMappingRegistry { let legacy_issuer_identifier = LegacyDid::from(legacy_issuer_identifier); let legacy_identifier = ResourceIdentifier::from(legacy_identifier); let new_identifier = ResourceIdentifier::from(new_identifier); - let transaction = legacy_mapping_registry::build_create_resource_mapping_transaction( + legacy_mapping_registry::build_create_resource_mapping_transaction( &client.0, &from, &did, @@ -144,8 +113,9 @@ impl LegacyMappingRegistry { &new_identifier, ) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildCreateResourceMappingEndorsingData)] @@ -160,7 +130,7 @@ impl LegacyMappingRegistry { let legacy_issuer_identifier = LegacyDid::from(legacy_issuer_identifier); let legacy_identifier = ResourceIdentifier::from(legacy_identifier); let new_identifier = ResourceIdentifier::from(new_identifier); - let data = legacy_mapping_registry::build_create_resource_mapping_endorsing_data( + legacy_mapping_registry::build_create_resource_mapping_endorsing_data( &client.0, &did, &legacy_issuer_identifier, @@ -168,39 +138,9 @@ impl LegacyMappingRegistry { &new_identifier, ) .await - .as_js()?; - Ok(TransactionEndorsingDataWrapper(Rc::new(data))) - } - - #[wasm_bindgen(js_name = buildCreateResourceMappingSignedTransaction)] - pub async fn build_create_resource_mapping_signed_transaction( - client: &LedgerClientWrapper, - from: &str, - did: &str, - legacy_issuer_identifier: &str, - legacy_identifier: &str, - new_identifier: &str, - signature_data: JsValue, - ) -> Result { - let from = Address::from(from); - let did = DID::from(did); - let legacy_issuer_identifier = LegacyDid::from(legacy_issuer_identifier); - let legacy_identifier = ResourceIdentifier::from(legacy_identifier); - let new_identifier = ResourceIdentifier::from(new_identifier); - let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - let transaction = - legacy_mapping_registry::build_create_resource_mapping_signed_transaction( - &client.0, - &from, - &did, - &legacy_issuer_identifier, - &legacy_identifier, - &new_identifier, - &signature_data, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionEndorsingDataWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildGetResourceMappingTransaction)] @@ -209,13 +149,14 @@ impl LegacyMappingRegistry { legacy_identifier: &str, ) -> Result { let legacy_identifier = ResourceIdentifier::from(legacy_identifier); - let transaction = legacy_mapping_registry::build_get_resource_mapping_transaction( + legacy_mapping_registry::build_get_resource_mapping_transaction( &client.0, &legacy_identifier, ) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = parseResourceMappingResult)] diff --git a/vdr/wasm/src/contracts/mod.rs b/vdr/wasm/src/contracts/mod.rs index 7de90861..cbaf14f4 100644 --- a/vdr/wasm/src/contracts/mod.rs +++ b/vdr/wasm/src/contracts/mod.rs @@ -2,6 +2,7 @@ pub mod credential_definition_registry; pub mod did_ethr_registry; pub mod did_indy_registry; pub mod did_resolver; +pub mod endorsing; pub mod legacy_mapping_registry; pub mod role_control; pub mod schema_registry; diff --git a/vdr/wasm/src/contracts/role_control.rs b/vdr/wasm/src/contracts/role_control.rs index 905e98e0..a6ced9f2 100644 --- a/vdr/wasm/src/contracts/role_control.rs +++ b/vdr/wasm/src/contracts/role_control.rs @@ -1,5 +1,4 @@ use indy_besu_vdr::{role_control, Address, Role}; -use std::rc::Rc; use wasm_bindgen::prelude::*; use crate::{ @@ -23,11 +22,11 @@ impl RoleControl { let role = Role::try_from(role).as_js()?; let from = Address::from(from); let account = Address::from(account); - let transaction = - role_control::build_assign_role_transaction(&client.0, &from, &role, &account) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + role_control::build_assign_role_transaction(&client.0, &from, &role, &account) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildRevokeRoleTransaction)] @@ -40,11 +39,11 @@ impl RoleControl { let role = Role::try_from(role).as_js()?; let from = Address::from(from); let account = Address::from(account); - let transaction = - role_control::build_revoke_role_transaction(&client.0, &from, &role, &account) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + role_control::build_revoke_role_transaction(&client.0, &from, &role, &account) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildHasRoleTransaction)] @@ -55,10 +54,11 @@ impl RoleControl { ) -> Result { let role = Role::try_from(role).as_js()?; let account = Address::from(account); - let transaction = role_control::build_has_role_transaction(&client.0, &role, &account) + role_control::build_has_role_transaction(&client.0, &role, &account) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildGetRoleTransaction)] @@ -67,10 +67,11 @@ impl RoleControl { account: &str, ) -> Result { let account = Address::from(account); - let transaction = role_control::build_get_role_transaction(&client.0, &account) + role_control::build_get_role_transaction(&client.0, &account) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = parseHasRoleResult)] diff --git a/vdr/wasm/src/contracts/schema_registry.rs b/vdr/wasm/src/contracts/schema_registry.rs index c010e3a7..79405348 100644 --- a/vdr/wasm/src/contracts/schema_registry.rs +++ b/vdr/wasm/src/contracts/schema_registry.rs @@ -1,4 +1,4 @@ -use indy_besu_vdr::{schema_registry, Address, Schema, SchemaId, SignatureData}; +use indy_besu_vdr::{schema_registry, Address, Schema, SchemaId, DID}; use std::rc::Rc; use wasm_bindgen::prelude::*; @@ -17,48 +17,26 @@ impl SchemaRegistry { pub async fn build_create_schema_transaction( client: &LedgerClientWrapper, from: &str, - schema: JsValue, + schema: &SchemaWrapper, ) -> Result { - let schema: Schema = serde_wasm_bindgen::from_value(schema)?; let address = Address::from(from); - let transaction = - schema_registry::build_create_schema_transaction(&client.0, &address, &schema) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + schema_registry::build_create_schema_transaction(&client.0, &address, &schema.0) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildCreateSchemaEndorsingData)] pub async fn build_create_schema_endorsing_data( client: &LedgerClientWrapper, - schema: JsValue, + schema: &SchemaWrapper, ) -> Result { - let schema: Schema = serde_wasm_bindgen::from_value(schema)?; - let data = schema_registry::build_create_schema_endorsing_data(&client.0, &schema) + schema_registry::build_create_schema_endorsing_data(&client.0, &schema.0) .await - .as_js()?; - Ok(TransactionEndorsingDataWrapper(Rc::new(data))) - } - - #[wasm_bindgen(js_name = buildCreateSchemaSignedTransaction)] - pub async fn build_create_schema_signed_transaction( - client: &LedgerClientWrapper, - from: &str, - schema: JsValue, - signature_data: JsValue, - ) -> Result { - let schema: Schema = serde_wasm_bindgen::from_value(schema)?; - let address = Address::from(from); - let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - let transaction = schema_registry::build_create_schema_signed_transaction( - &client.0, - &address, - &schema, - &signature_data, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionEndorsingDataWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildResolveSchemaTransaction)] @@ -67,10 +45,11 @@ impl SchemaRegistry { id: &str, ) -> Result { let id = SchemaId::from(id); - let transaction = schema_registry::build_resolve_schema_transaction(&client.0, &id) + schema_registry::build_resolve_schema_transaction(&client.0, &id) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = parseResolveSchemaResult)] @@ -84,12 +63,62 @@ impl SchemaRegistry { } #[wasm_bindgen(js_name = resolveSchema)] - pub async fn resolve_schema(client: &LedgerClientWrapper, id: &str) -> Result { + pub async fn resolve_schema(client: &LedgerClientWrapper, id: &str) -> Result { let id = SchemaId::from(id); - let schema = schema_registry::resolve_schema(&client.0, &id) + schema_registry::resolve_schema(&client.0, &id) .await - .as_js()?; - let result: JsValue = serde_wasm_bindgen::to_value(&schema)?; - Ok(result) + .as_js() + .map(SchemaWrapper::from) + .map_err(JsValue::from) + } +} + +#[wasm_bindgen(js_name = Schema)] +pub struct SchemaWrapper(pub(crate) Rc); + +#[wasm_bindgen(js_class = Schema)] +impl SchemaWrapper { + #[wasm_bindgen(constructor)] + pub fn new( + issuer_id: String, + name: String, + version: String, + attr_names: Vec, + ) -> SchemaWrapper { + SchemaWrapper(Rc::new(Schema { + issuer_id: DID::from(issuer_id.as_str()), + name, + version, + attr_names: attr_names.iter().cloned().collect(), + })) + } + + #[wasm_bindgen(js_name = getId)] + pub fn get_id(&self) -> String { + self.0.id().as_ref().to_string() + } + + #[wasm_bindgen(js_name = toString)] + pub fn to_string(&self) -> Result { + self.0.to_string().as_js().map_err(JsValue::from) + } + + #[wasm_bindgen(js_name = fromString)] + pub fn from_string(string: &str) -> Result { + Schema::from_string(string) + .as_js() + .map(SchemaWrapper::from) + .map_err(JsValue::from) + } + + #[wasm_bindgen(js_name = asValue)] + pub fn as_value(&self) -> Result { + serde_wasm_bindgen::to_value(&*self.0).map_err(JsValue::from) + } +} + +impl From for SchemaWrapper { + fn from(data: Schema) -> SchemaWrapper { + SchemaWrapper(Rc::new(data)) } } diff --git a/vdr/wasm/src/contracts/validator_control.rs b/vdr/wasm/src/contracts/validator_control.rs index 34935328..b317622a 100644 --- a/vdr/wasm/src/contracts/validator_control.rs +++ b/vdr/wasm/src/contracts/validator_control.rs @@ -1,5 +1,4 @@ use indy_besu_vdr::{validator_control, Address}; -use std::rc::Rc; use wasm_bindgen::prelude::*; use crate::{ @@ -21,14 +20,11 @@ impl ValidatorControl { ) -> Result { let from = Address::from(from); let validator_address = Address::from(validator_address); - let transaction = validator_control::build_add_validator_transaction( - &client.0, - &from, - &validator_address, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + validator_control::build_add_validator_transaction(&client.0, &from, &validator_address) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildRemoveValidatorTransaction)] @@ -39,24 +35,22 @@ impl ValidatorControl { ) -> Result { let from = Address::from(from); let validator_address = Address::from(validator_address); - let transaction = validator_control::build_remove_validator_transaction( - &client.0, - &from, - &validator_address, - ) - .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + validator_control::build_remove_validator_transaction(&client.0, &from, &validator_address) + .await + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = buildGetValidatorsTransaction)] pub async fn build_get_validators_transaction( client: &LedgerClientWrapper, ) -> Result { - let transaction = validator_control::build_get_validators_transaction(&client.0) + validator_control::build_get_validators_transaction(&client.0) .await - .as_js()?; - Ok(TransactionWrapper(Rc::new(transaction))) + .as_js() + .map(TransactionWrapper::from) + .map_err(JsValue::from) } #[wasm_bindgen(js_name = parseGetValidatorsResult)] diff --git a/vdr/wasm/src/transaction.rs b/vdr/wasm/src/transaction.rs index 7ca00ed5..92656dfb 100644 --- a/vdr/wasm/src/transaction.rs +++ b/vdr/wasm/src/transaction.rs @@ -1,40 +1,59 @@ use indy_besu_vdr::{SignatureData, Transaction, TransactionEndorsingData}; -use std::rc::Rc; +use std::cell::RefCell; use wasm_bindgen::prelude::*; -use crate::error::Result; +use crate::error::{JsResult, Result}; #[wasm_bindgen(js_name = Transaction)] -pub struct TransactionWrapper(pub(crate) Rc); +pub struct TransactionWrapper(pub(crate) RefCell); #[wasm_bindgen(js_class = Transaction)] impl TransactionWrapper { pub fn to(&self) -> Result { - Ok(self.0.to.to_string()) + Ok(self.0.borrow().to.to_string()) } #[wasm_bindgen(js_name = getSigningBytes)] pub fn get_signing_bytes(&self) -> Result> { - let bytes = self.0.get_signing_bytes().unwrap(); + let bytes = self.0.borrow().get_signing_bytes().as_js()?; Ok(bytes) } #[wasm_bindgen(js_name = setSignature)] pub fn set_signature(&mut self, signature_data: JsValue) -> Result<()> { let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; - self.0.set_signature(signature_data); + self.0.get_mut().set_signature(signature_data); Ok(()) } } +impl From for TransactionWrapper { + fn from(transaction: Transaction) -> TransactionWrapper { + TransactionWrapper(RefCell::new(transaction)) + } +} + #[wasm_bindgen(js_name = TransactionEndorsingData)] -pub struct TransactionEndorsingDataWrapper(pub(crate) Rc); +pub struct TransactionEndorsingDataWrapper(pub(crate) RefCell); #[wasm_bindgen(js_class = TransactionEndorsingData)] impl TransactionEndorsingDataWrapper { #[wasm_bindgen(js_name = getSigningBytes)] pub fn get_signing_bytes(&self) -> Result> { - let bytes = self.0.get_signing_bytes().unwrap(); + let bytes = self.0.borrow().get_signing_bytes().as_js()?; Ok(bytes) } + + #[wasm_bindgen(js_name = setSignature)] + pub fn set_signature(&mut self, signature_data: JsValue) -> Result<()> { + let signature_data: SignatureData = serde_wasm_bindgen::from_value(signature_data)?; + self.0.get_mut().set_signature(signature_data); + Ok(()) + } +} + +impl From for TransactionEndorsingDataWrapper { + fn from(data: TransactionEndorsingData) -> TransactionEndorsingDataWrapper { + TransactionEndorsingDataWrapper(RefCell::new(data)) + } } diff --git a/vdr/wrappers/python/demo/test.py b/vdr/wrappers/python/demo/test.py index 5408e1be..6572bd7b 100644 --- a/vdr/wrappers/python/demo/test.py +++ b/vdr/wrappers/python/demo/test.py @@ -19,6 +19,7 @@ network = 'test' project_root = f"{os.getcwd()}/../../.." + def sign(secret: str, data: bytes): signature = keys.PrivateKey(bytearray.fromhex(secret)).sign_msg_hash(data) rec_id = int(signature[-1:][0]) @@ -54,47 +55,45 @@ async def demo(): print("2. Publish DID") did = 'did:ethr:' + identity['address'] service_attribute = {"serviceEndpoint": "http://10.0.0.2", "type": "TestService"} - endorsing_data = await build_did_set_attribute_endorsing_data(client, did, json.dumps(service_attribute), 1000) + endorsing_data = await DidEthrRegistry.build_did_set_attribute_endorsing_data(client, did, service_attribute, 1000) identity_signature = sign(identity["secret"], endorsing_data.get_signing_bytes()) - transaction = await build_did_set_attribute_signed_transaction(client, trustee["address"], did, - json.dumps(service_attribute), 1000, - identity_signature) + endorsing_data.set_signature(identity_signature) + transaction = await Endorsement.build_endorsement_transaction(client, trustee["address"], endorsing_data) trustee_signature = sign(trustee["secret"], transaction.get_signing_bytes()) transaction.set_signature(trustee_signature) txn_hash = await client.submit_transaction(transaction) print(' Transaction hash: ' + bytes(txn_hash).hex()) receipt = await client.get_receipt(txn_hash) - print(' Transaction receipt: ' + str(receipt)) + print(' Transaction receipt: ' + receipt) print("3. Resolve DID Document") - resolved_did_doc = await resolve_did(client, did, None) + resolved_did_doc = await DidResolver.resolve_did(client, did, None) print(' Resolved DID Document:' + resolved_did_doc) print("4. Publish Schema") name = ''.join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(6)) - schema_id = did + '/anoncreds/v0/SCHEMA/' + name + '/1.0.0' - schema = { - "attrNames": ["First Name", "Last Name"], - "issuerId": did, - "name": name, - "version": "1.0.0" - } - endorsing_data = await build_create_schema_endorsing_data(client, json.dumps(schema)) + schema = Schema(did, name, "1.0.0", ["First Name", "Last Name"]) + endorsing_data = await SchemaRegistry.build_create_schema_endorsing_data(client, schema) identity_signature = sign(identity["secret"], endorsing_data.get_signing_bytes()) - transaction = await build_create_schema_signed_transaction(client, - trustee["address"], - json.dumps(schema), - identity_signature) + endorsing_data.set_signature(identity_signature) + + # Author: serialize endorsement data into JSON string and pass it to trustee + endorsing_data_json = endorsing_data.to_string() + print(' Schema transaction endorsement data: ' + endorsing_data_json) + # Trustee: deserialize endorsement data form json + schema_endorsing_data = TransactionEndorsingData.from_string(endorsing_data_json) + transaction = await Endorsement.build_endorsement_transaction(client, trustee["address"], schema_endorsing_data) trustee_signature = sign(trustee["secret"], transaction.get_signing_bytes()) transaction.set_signature(trustee_signature) txn_hash = await client.submit_transaction(transaction) print(' Transaction hash: ' + bytes(txn_hash).hex()) receipt = await client.get_receipt(txn_hash) - print(' Transaction receipt: ' + str(receipt)) + print(' Transaction receipt: ' + receipt) print("5. Resolve Schema") - resolved_schema = await resolve_schema(client, schema_id) - print(' Resolved Schema:' + resolved_schema) + resolved_schema = await SchemaRegistry.resolve_schema(client, schema.id) + print(' Resolved Schema:' + resolved_schema.to_string()) + if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(demo()) diff --git a/vdr/wrappers/python/indy_besu_vdr/__init__.py b/vdr/wrappers/python/indy_besu_vdr/__init__.py index df8e7434..49ed5766 100644 --- a/vdr/wrappers/python/indy_besu_vdr/__init__.py +++ b/vdr/wrappers/python/indy_besu_vdr/__init__.py @@ -1,5 +1,18 @@ """Indy2 VDR Python wrapper""" -from .indy_besu_vdr import ( +from .types import ( + Transaction, + TransactionEndorsingData, + DidIndyRegistry, + DidEthrRegistry, + DidResolver, + Schema, + SchemaRegistry, + CredentialDefinition, + CredentialDefinitionRegistry, + LegacyMapping, + Endorsement, + RoleControl, + ValidatorControl, InternalError, Status, TransactionType, @@ -9,8 +22,6 @@ PingStatus, SignatureData, LedgerClient, - Transaction, - TransactionEndorsingData, DidAttributeChanged, DidDelegateChanged, DidOwnerChanged, @@ -21,90 +32,22 @@ DidResolutionOptions, EventQuery, EventLog, - build_add_validator_transaction, - build_assign_role_transaction, - build_create_credential_definition_transaction, - build_create_did_transaction, - build_create_did_endorsing_data, - build_create_did_signed_transaction, - build_create_did_signed_transaction, - build_did_change_owner_transaction, - build_did_change_owner_endorsing_data, - build_did_change_owner_signed_transaction, - build_did_add_delegate_transaction, - build_did_add_delegate_endorsing_data, - build_did_add_delegate_signed_transaction, - build_did_revoke_delegate_transaction, - build_did_revoke_delegate_endorsing_data, - build_did_revoke_delegate_signed_transaction, - build_did_set_attribute_transaction, - build_did_set_attribute_endorsing_data, - build_did_set_attribute_signed_transaction, - build_did_revoke_attribute_transaction, - build_did_revoke_attribute_endorsing_data, - build_did_revoke_attribute_signed_transaction, - build_get_did_owner_transaction, - build_get_did_changed_transaction, - build_get_identity_nonce_transaction, - build_get_did_events_query, - parse_did_changed_result, - parse_did_owner_result, - parse_did_nonce_result, - parse_did_attribute_changed_event_response, - parse_did_delegate_changed_event_response, - parse_did_owner_changed_event_response, - parse_did_event_response, - build_create_did_transaction, - build_update_did_transaction, - build_update_did_endorsing_data, - build_update_did_signed_transaction, - build_deactivate_did_transaction, - build_deactivate_did_endorsing_data, - build_deactivate_did_signed_transaction, - build_resolve_did_transaction, - parse_resolve_did_result, - resolve_did, - build_create_schema_transaction, - build_create_schema_endorsing_data, - build_create_schema_signed_transaction, - build_resolve_schema_transaction, - parse_resolve_schema_result, - resolve_schema, - build_create_credential_definition_transaction, - build_create_credential_definition_endorsing_data, - build_create_credential_definition_signed_transaction, - build_create_did_mapping_transaction, - build_create_did_mapping_endorsing_data, - build_create_did_mapping_signed_transaction, - build_get_did_mapping_transaction, - parse_did_mapping_result, - build_create_resource_mapping_transaction, - build_create_resource_mapping_endorsing_data, - build_create_resource_mapping_signed_transaction, - build_get_resource_mapping_transaction, - parse_resource_mapping_result, - build_resolve_credential_definition_transaction, - parse_resolve_credential_definition_result, - resolve_credential_definition, - build_get_role_transaction, - build_get_validators_transaction, - build_has_role_transaction, - build_remove_validator_transaction, - build_resolve_did_transaction, - build_resolve_schema_transaction, - resolve_schema, - build_revoke_role_transaction, - build_update_did_transaction, - parse_get_role_result, - parse_get_validators_result, - parse_has_role_result, - parse_resolve_credential_definition_result, - resolve_credential_definition, - parse_resolve_did_result, - parse_resolve_schema_result ) __all__ = ( + "Transaction", + "TransactionEndorsingData", + "DidIndyRegistry", + "DidEthrRegistry", + "DidResolver", + "Schema", + "SchemaRegistry", + "CredentialDefinition", + "CredentialDefinitionRegistry", + "LegacyMapping", + "Endorsement", + "RoleControl", + "ValidatorControl", "InternalError", "Status", "TransactionType", @@ -114,8 +57,6 @@ "PingStatus", "SignatureData", "LedgerClient", - "Transaction", - "TransactionEndorsingData", "DidAttributeChanged", "DidDelegateChanged", "DidOwnerChanged", @@ -126,74 +67,4 @@ "DidResolutionOptions", "EventQuery", "EventLog", - "build_add_validator_transaction", - "build_assign_role_transaction", - "build_create_credential_definition_transaction", - "build_create_credential_definition_endorsing_data", - "build_create_credential_definition_signed_transaction", - "build_create_did_mapping_transaction", - "build_create_did_mapping_endorsing_data", - "build_create_did_mapping_signed_transaction", - "build_get_did_mapping_transaction", - "parse_did_mapping_result", - "build_create_resource_mapping_transaction", - "build_create_resource_mapping_endorsing_data", - "build_create_resource_mapping_signed_transaction", - "build_get_resource_mapping_transaction", - "parse_resource_mapping_result", - "build_create_did_transaction", - "build_create_did_endorsing_data", - "build_create_did_signed_transaction", - "build_did_change_owner_transaction", - "build_did_change_owner_signed_transaction", - "build_did_change_owner_endorsing_data", - "build_did_add_delegate_transaction", - "build_did_add_delegate_signed_transaction", - "build_did_add_delegate_endorsing_data", - "build_did_revoke_delegate_transaction", - "build_did_revoke_delegate_signed_transaction", - "build_did_revoke_delegate_endorsing_data", - "build_did_set_attribute_transaction", - "build_did_set_attribute_endorsing_data", - "build_did_set_attribute_signed_transaction", - "build_did_revoke_attribute_transaction", - "build_did_revoke_attribute_endorsing_data", - "build_did_revoke_attribute_signed_transaction", - "build_get_did_owner_transaction", - "build_get_did_changed_transaction", - "build_get_identity_nonce_transaction", - "build_get_did_events_query", - "parse_did_changed_result", - "parse_did_owner_result", - "parse_did_nonce_result", - "parse_did_attribute_changed_event_response", - "parse_did_delegate_changed_event_response", - "parse_did_owner_changed_event_response", - "parse_did_event_response", - "resolve_did", - "resolve_schema", - "resolve_credential_definition", - "build_create_schema_transaction", - "build_create_schema_endorsing_data", - "build_create_schema_signed_transaction", - "build_deactivate_did_transaction", - "build_deactivate_did_endorsing_data", - "build_deactivate_did_signed_transaction", - "build_get_role_transaction", - "build_get_validators_transaction", - "build_has_role_transaction", - "build_remove_validator_transaction", - "build_resolve_credential_definition_transaction", - "build_resolve_did_transaction", - "build_resolve_schema_transaction", - "build_revoke_role_transaction", - "build_update_did_transaction", - "build_update_did_endorsing_data", - "build_update_did_signed_transaction", - "parse_get_role_result", - "parse_get_validators_result", - "parse_has_role_result", - "parse_resolve_credential_definition_result", - "parse_resolve_did_result", - "parse_resolve_schema_result" ) diff --git a/vdr/wrappers/python/indy_besu_vdr/indy_besu_vdr.py b/vdr/wrappers/python/indy_besu_vdr/indy_besu_vdr.py index 74a37750..8b4adb79 100644 --- a/vdr/wrappers/python/indy_besu_vdr/indy_besu_vdr.py +++ b/vdr/wrappers/python/indy_besu_vdr/indy_besu_vdr.py @@ -477,109 +477,93 @@ def _uniffi_check_contract_api_version(lib): raise InternalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") def _uniffi_check_api_checksums(lib): - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_add_validator_transaction() != 2909: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_add_validator_transaction() != 49434: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_assign_role_transaction() != 13494: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_assign_role_transaction() != 19303: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_credential_definition_endorsing_data() != 55676: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_credential_definition_endorsing_data() != 31555: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_credential_definition_signed_transaction() != 38063: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_credential_definition_transaction() != 48372: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_credential_definition_transaction() != 27654: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_endorsing_data() != 19847: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_endorsing_data() != 54516: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_mapping_endorsing_data() != 3412: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_mapping_endorsing_data() != 23405: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_mapping_transaction() != 64659: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_mapping_signed_transaction() != 52132: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_transaction() != 17427: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_mapping_transaction() != 4679: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_resource_mapping_endorsing_data() != 38201: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_signed_transaction() != 40911: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_resource_mapping_transaction() != 6041: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_transaction() != 55435: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_schema_endorsing_data() != 24765: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_resource_mapping_endorsing_data() != 16022: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_schema_transaction() != 22681: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_resource_mapping_signed_transaction() != 21759: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_deactivate_did_endorsing_data() != 10435: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_resource_mapping_transaction() != 49732: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_deactivate_did_transaction() != 52605: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_schema_endorsing_data() != 53121: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_add_delegate_endorsing_data() != 24694: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_schema_signed_transaction() != 19440: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_add_delegate_transaction() != 578: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_schema_transaction() != 31018: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_change_owner_endorsing_data() != 46497: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_deactivate_did_endorsing_data() != 24992: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_change_owner_transaction() != 30801: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_deactivate_did_signed_transaction() != 50123: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_attribute_endorsing_data() != 54740: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_deactivate_did_transaction() != 52099: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_attribute_transaction() != 63668: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_add_delegate_endorsing_data() != 21660: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_delegate_endorsing_data() != 50029: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_add_delegate_signed_transaction() != 6684: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_delegate_transaction() != 52636: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_add_delegate_transaction() != 5942: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_set_attribute_endorsing_data() != 23389: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_change_owner_endorsing_data() != 21431: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_set_attribute_transaction() != 60165: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_change_owner_signed_transaction() != 25381: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_endorsement_transaction() != 7484: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_change_owner_transaction() != 41898: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_did_changed_transaction() != 53752: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_attribute_endorsing_data() != 24316: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_did_events_query() != 7741: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_attribute_signed_transaction() != 59037: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_did_mapping_transaction() != 14270: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_attribute_transaction() != 59289: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_did_owner_transaction() != 51424: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_delegate_endorsing_data() != 14031: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_identity_nonce_transaction() != 6229: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_delegate_signed_transaction() != 7578: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_resource_mapping_transaction() != 48831: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_delegate_transaction() != 55423: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_role_transaction() != 23984: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_set_attribute_endorsing_data() != 8983: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_validators_transaction() != 49058: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_set_attribute_signed_transaction() != 64551: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_has_role_transaction() != 21081: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_set_attribute_transaction() != 65451: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_remove_validator_transaction() != 65518: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_did_changed_transaction() != 41555: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_resolve_credential_definition_transaction() != 22183: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_did_events_query() != 35752: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_resolve_did_transaction() != 30138: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_did_mapping_transaction() != 9840: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_resolve_schema_transaction() != 23161: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_did_owner_transaction() != 29722: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_revoke_role_transaction() != 31148: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_identity_nonce_transaction() != 21686: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_update_did_endorsing_data() != 33282: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_resource_mapping_transaction() != 26696: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_update_did_transaction() != 54343: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_role_transaction() != 34920: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_credential_definition_from_string() != 58541: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_validators_transaction() != 16117: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_credential_definition_get_id() != 41473: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_has_role_transaction() != 35189: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_remove_validator_transaction() != 23482: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_resolve_credential_definition_transaction() != 50274: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_resolve_did_transaction() != 13420: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_resolve_schema_transaction() != 25036: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_revoke_role_transaction() != 41767: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_update_did_endorsing_data() != 47376: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_update_did_signed_transaction() != 42885: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_update_did_transaction() != 9871: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_credential_definition_to_string() != 10206: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_did_attribute_changed_event_response() != 27285: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -599,68 +583,61 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_get_role_result() != 24565: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_get_validators_result() != 34604: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_get_validators_result() != 47252: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_has_role_result() != 16372: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_resolve_credential_definition_result() != 30087: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_resolve_credential_definition_result() != 21671: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_resolve_did_result() != 15878: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_resolve_did_result() != 27898: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_resolve_schema_result() != 15793: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_resolve_schema_result() != 64693: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_resource_mapping_result() != 47018: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_resolve_credential_definition() != 411: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_resolve_credential_definition() != 55906: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_resolve_did() != 9418: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_resolve_did() != 45456: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_resolve_schema() != 37103: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_resolve_schema() != 2703: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_method_ledgerclient_get_receipt() != 56453: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_schema_from_string() != 25235: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_method_ledgerclient_ping() != 64834: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_schema_get_id() != 23981: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_method_ledgerclient_query_events() != 44751: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_schema_to_string() != 46812: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_method_ledgerclient_submit_transaction() != 37630: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_create() != 37606: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_method_transaction_get_signing_bytes() != 1239: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_endorsing_data_create() != 21138: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_method_transaction_set_signature() != 39952: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_endorsing_data_from_string() != 34627: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_method_transactionendorsingdata_get_signing_bytes() != 64283: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_endorsing_data_get_signing_bytes() != 44811: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_constructor_eventquery_new() != 57276: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_endorsing_data_to_string() != 63969: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_constructor_ledgerclient_new() != 954: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_from_string() != 62148: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_get_signing_bytes() != 41505: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_to_string() != 21025: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_indy_besu_vdr_uniffi_checksum_method_ledgerclient_get_receipt() != 56453: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_indy_besu_vdr_uniffi_checksum_method_ledgerclient_ping() != 64834: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_indy_besu_vdr_uniffi_checksum_method_ledgerclient_query_events() != 64611: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_indy_besu_vdr_uniffi_checksum_constructor_transaction_new() != 38765: + if lib.uniffi_indy_besu_vdr_uniffi_checksum_method_ledgerclient_submit_transaction() != 22126: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_indy_besu_vdr_uniffi_checksum_constructor_ledgerclient_new() != 954: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") # A ctypes library to expose the extern-C FFI definitions. # This is an implementation detail which will be called internally by the public API. _UniffiLib = _uniffi_load_indirect() -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_clone_eventquery.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_clone_eventquery.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_free_eventquery.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_free_eventquery.restype = None -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_constructor_eventquery_new.argtypes = ( - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_constructor_eventquery_new.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_clone_ledgerclient.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -691,61 +668,14 @@ def _uniffi_check_api_checksums(lib): _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_ledgerclient_ping.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_ledgerclient_query_events.argtypes = ( ctypes.c_void_p, - ctypes.c_void_p, + _UniffiRustBuffer, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_ledgerclient_query_events.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_ledgerclient_submit_transaction.argtypes = ( - ctypes.c_void_p, - ctypes.c_void_p, -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_ledgerclient_submit_transaction.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_clone_transaction.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_clone_transaction.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_free_transaction.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_free_transaction.restype = None -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_constructor_transaction_new.argtypes = ( - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - ctypes.c_uint64, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_constructor_transaction_new.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_transaction_get_signing_bytes.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_transaction_get_signing_bytes.restype = _UniffiRustBuffer -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_transaction_set_signature.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_transaction_set_signature.restype = None -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_clone_transactionendorsingdata.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_clone_transactionendorsingdata.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_free_transactionendorsingdata.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_free_transactionendorsingdata.restype = None -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_transactionendorsingdata_get_signing_bytes.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_transactionendorsingdata_get_signing_bytes.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_ledgerclient_submit_transaction.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_add_validator_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -764,13 +694,6 @@ def _uniffi_check_api_checksums(lib): _UniffiRustBuffer, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_credential_definition_endorsing_data.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_credential_definition_signed_transaction.argtypes = ( - ctypes.c_void_p, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_credential_definition_signed_transaction.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_credential_definition_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -791,16 +714,6 @@ def _uniffi_check_api_checksums(lib): _UniffiRustBuffer, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_did_mapping_endorsing_data.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_did_mapping_signed_transaction.argtypes = ( - ctypes.c_void_p, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_did_mapping_signed_transaction.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_did_mapping_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -810,14 +723,6 @@ def _uniffi_check_api_checksums(lib): _UniffiRustBuffer, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_did_mapping_transaction.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_did_signed_transaction.argtypes = ( - ctypes.c_void_p, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_did_signed_transaction.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_did_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -833,16 +738,6 @@ def _uniffi_check_api_checksums(lib): _UniffiRustBuffer, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_resource_mapping_endorsing_data.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_resource_mapping_signed_transaction.argtypes = ( - ctypes.c_void_p, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_resource_mapping_signed_transaction.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_resource_mapping_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -857,13 +752,6 @@ def _uniffi_check_api_checksums(lib): _UniffiRustBuffer, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_schema_endorsing_data.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_schema_signed_transaction.argtypes = ( - ctypes.c_void_p, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_schema_signed_transaction.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_schema_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -875,13 +763,6 @@ def _uniffi_check_api_checksums(lib): _UniffiRustBuffer, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_deactivate_did_endorsing_data.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_deactivate_did_signed_transaction.argtypes = ( - ctypes.c_void_p, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_deactivate_did_signed_transaction.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_deactivate_did_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -896,16 +777,6 @@ def _uniffi_check_api_checksums(lib): ctypes.c_uint64, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_add_delegate_endorsing_data.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_add_delegate_signed_transaction.argtypes = ( - ctypes.c_void_p, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - ctypes.c_uint64, - _UniffiRustBuffer, -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_add_delegate_signed_transaction.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_add_delegate_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -921,14 +792,6 @@ def _uniffi_check_api_checksums(lib): _UniffiRustBuffer, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_change_owner_endorsing_data.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_change_owner_signed_transaction.argtypes = ( - ctypes.c_void_p, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_change_owner_signed_transaction.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_change_owner_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -942,14 +805,6 @@ def _uniffi_check_api_checksums(lib): _UniffiRustBuffer, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_revoke_attribute_endorsing_data.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_revoke_attribute_signed_transaction.argtypes = ( - ctypes.c_void_p, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_revoke_attribute_signed_transaction.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_revoke_attribute_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -964,15 +819,6 @@ def _uniffi_check_api_checksums(lib): _UniffiRustBuffer, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_revoke_delegate_endorsing_data.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_revoke_delegate_signed_transaction.argtypes = ( - ctypes.c_void_p, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_revoke_delegate_signed_transaction.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_revoke_delegate_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -988,23 +834,20 @@ def _uniffi_check_api_checksums(lib): ctypes.c_uint64, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_set_attribute_endorsing_data.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_set_attribute_signed_transaction.argtypes = ( +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_set_attribute_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, _UniffiRustBuffer, _UniffiRustBuffer, ctypes.c_uint64, - _UniffiRustBuffer, ) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_set_attribute_signed_transaction.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_set_attribute_transaction.argtypes = ( +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_set_attribute_transaction.restype = ctypes.c_void_p +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_endorsement_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, _UniffiRustBuffer, - _UniffiRustBuffer, - ctypes.c_uint64, ) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_set_attribute_transaction.restype = ctypes.c_void_p +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_endorsement_transaction.restype = ctypes.c_void_p _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_get_did_changed_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -1086,21 +929,28 @@ def _uniffi_check_api_checksums(lib): _UniffiRustBuffer, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_update_did_endorsing_data.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_update_did_signed_transaction.argtypes = ( +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_update_did_transaction.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, _UniffiRustBuffer, _UniffiRustBuffer, - _UniffiRustBuffer, ) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_update_did_signed_transaction.restype = ctypes.c_void_p -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_update_did_transaction.argtypes = ( - ctypes.c_void_p, +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_update_did_transaction.restype = ctypes.c_void_p +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_credential_definition_from_string.argtypes = ( _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_credential_definition_from_string.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_credential_definition_get_id.argtypes = ( _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_credential_definition_get_id.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_credential_definition_to_string.argtypes = ( _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_update_did_transaction.restype = ctypes.c_void_p +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_credential_definition_to_string.restype = _UniffiRustBuffer _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_parse_did_attribute_changed_event_response.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -1207,6 +1057,75 @@ def _uniffi_check_api_checksums(lib): _UniffiRustBuffer, ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_resolve_schema.restype = ctypes.c_void_p +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_schema_from_string.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_schema_from_string.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_schema_get_id.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_schema_get_id.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_schema_to_string.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_schema_to_string.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_create.argtypes = ( + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.c_uint64, + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_create.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_endorsing_data_create.argtypes = ( + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_endorsing_data_create.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_endorsing_data_from_string.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_endorsing_data_from_string.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_endorsing_data_get_signing_bytes.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_endorsing_data_get_signing_bytes.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_endorsing_data_to_string.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_endorsing_data_to_string.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_from_string.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_from_string.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_get_signing_bytes.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_get_signing_bytes.restype = _UniffiRustBuffer +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_to_string.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_to_string.restype = _UniffiRustBuffer _UniffiLib.ffi_indy_besu_vdr_uniffi_rustbuffer_alloc.argtypes = ( ctypes.c_int32, ctypes.POINTER(_UniffiRustCallStatus), @@ -1484,9 +1403,6 @@ def _uniffi_check_api_checksums(lib): _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_credential_definition_endorsing_data.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_credential_definition_endorsing_data.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_credential_definition_signed_transaction.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_credential_definition_signed_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_credential_definition_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_credential_definition_transaction.restype = ctypes.c_uint16 @@ -1496,90 +1412,63 @@ def _uniffi_check_api_checksums(lib): _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_mapping_endorsing_data.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_mapping_endorsing_data.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_mapping_signed_transaction.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_mapping_signed_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_mapping_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_mapping_transaction.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_signed_transaction.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_signed_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_did_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_resource_mapping_endorsing_data.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_resource_mapping_endorsing_data.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_resource_mapping_signed_transaction.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_resource_mapping_signed_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_resource_mapping_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_resource_mapping_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_schema_endorsing_data.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_schema_endorsing_data.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_schema_signed_transaction.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_schema_signed_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_schema_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_create_schema_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_deactivate_did_endorsing_data.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_deactivate_did_endorsing_data.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_deactivate_did_signed_transaction.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_deactivate_did_signed_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_deactivate_did_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_deactivate_did_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_add_delegate_endorsing_data.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_add_delegate_endorsing_data.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_add_delegate_signed_transaction.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_add_delegate_signed_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_add_delegate_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_add_delegate_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_change_owner_endorsing_data.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_change_owner_endorsing_data.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_change_owner_signed_transaction.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_change_owner_signed_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_change_owner_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_change_owner_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_attribute_endorsing_data.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_attribute_endorsing_data.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_attribute_signed_transaction.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_attribute_signed_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_attribute_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_attribute_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_delegate_endorsing_data.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_delegate_endorsing_data.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_delegate_signed_transaction.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_delegate_signed_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_delegate_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_revoke_delegate_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_set_attribute_endorsing_data.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_set_attribute_endorsing_data.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_set_attribute_signed_transaction.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_set_attribute_signed_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_set_attribute_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_did_set_attribute_transaction.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_endorsement_transaction.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_endorsement_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_did_changed_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_get_did_changed_transaction.restype = ctypes.c_uint16 @@ -1625,12 +1514,18 @@ def _uniffi_check_api_checksums(lib): _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_update_did_endorsing_data.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_update_did_endorsing_data.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_update_did_signed_transaction.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_update_did_signed_transaction.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_update_did_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_build_update_did_transaction.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_credential_definition_from_string.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_credential_definition_from_string.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_credential_definition_get_id.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_credential_definition_get_id.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_credential_definition_to_string.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_credential_definition_to_string.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_did_attribute_changed_event_response.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_parse_did_attribute_changed_event_response.restype = ctypes.c_uint16 @@ -1685,6 +1580,39 @@ def _uniffi_check_api_checksums(lib): _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_resolve_schema.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_resolve_schema.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_schema_from_string.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_schema_from_string.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_schema_get_id.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_schema_get_id.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_schema_to_string.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_schema_to_string.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_create.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_create.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_endorsing_data_create.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_endorsing_data_create.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_endorsing_data_from_string.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_endorsing_data_from_string.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_endorsing_data_get_signing_bytes.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_endorsing_data_get_signing_bytes.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_endorsing_data_to_string.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_endorsing_data_to_string.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_from_string.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_from_string.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_get_signing_bytes.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_get_signing_bytes.restype = ctypes.c_uint16 +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_to_string.argtypes = ( +) +_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_func_transaction_to_string.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_method_ledgerclient_get_receipt.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_method_ledgerclient_get_receipt.restype = ctypes.c_uint16 @@ -1697,24 +1625,9 @@ def _uniffi_check_api_checksums(lib): _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_method_ledgerclient_submit_transaction.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_method_ledgerclient_submit_transaction.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_method_transaction_get_signing_bytes.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_method_transaction_get_signing_bytes.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_method_transaction_set_signature.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_method_transaction_set_signature.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_method_transactionendorsingdata_get_signing_bytes.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_method_transactionendorsingdata_get_signing_bytes.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_constructor_eventquery_new.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_constructor_eventquery_new.restype = ctypes.c_uint16 _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_constructor_ledgerclient_new.argtypes = ( ) _UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_constructor_ledgerclient_new.restype = ctypes.c_uint16 -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_constructor_transaction_new.argtypes = ( -) -_UniffiLib.uniffi_indy_besu_vdr_uniffi_checksum_constructor_transaction_new.restype = ctypes.c_uint16 _UniffiLib.ffi_indy_besu_vdr_uniffi_uniffi_contract_version.argtypes = ( ) _UniffiLib.ffi_indy_besu_vdr_uniffi_uniffi_contract_version.restype = ctypes.c_uint32 @@ -1865,117 +1778,45 @@ def write(value, buf): -class EventQueryProtocol(typing.Protocol): - pass +class LedgerClientProtocol(typing.Protocol): + def get_receipt(self, hash: "bytes"): + raise NotImplementedError + def ping(self, ): + raise NotImplementedError + def query_events(self, query: "EventQuery"): + raise NotImplementedError + def submit_transaction(self, transaction: "Transaction"): + raise NotImplementedError -class EventQuery: +class LedgerClient: _pointer: ctypes.c_void_p - def __init__(self, address: "str",from_block: "typing.Optional[int]",to_block: "typing.Optional[int]",event_signature: "typing.Optional[str]",event_filter: "typing.Optional[str]"): - _UniffiConverterString.check_lower(address) + def __init__(self, chain_id: "int",node_address: "str",contract_configs: "typing.List[ContractConfig]",network: "typing.Optional[str]",quorum_config: "typing.Optional[QuorumConfig]"): + _UniffiConverterUInt64.check_lower(chain_id) - _UniffiConverterOptionalUInt64.check_lower(from_block) + _UniffiConverterString.check_lower(node_address) - _UniffiConverterOptionalUInt64.check_lower(to_block) + _UniffiConverterSequenceTypeContractConfig.check_lower(contract_configs) - _UniffiConverterOptionalString.check_lower(event_signature) + _UniffiConverterOptionalString.check_lower(network) - _UniffiConverterOptionalString.check_lower(event_filter) + _UniffiConverterOptionalTypeQuorumConfig.check_lower(quorum_config) - self._pointer = _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_constructor_eventquery_new, - _UniffiConverterString.lower(address), - _UniffiConverterOptionalUInt64.lower(from_block), - _UniffiConverterOptionalUInt64.lower(to_block), - _UniffiConverterOptionalString.lower(event_signature), - _UniffiConverterOptionalString.lower(event_filter)) + self._pointer = _rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_constructor_ledgerclient_new, + _UniffiConverterUInt64.lower(chain_id), + _UniffiConverterString.lower(node_address), + _UniffiConverterSequenceTypeContractConfig.lower(contract_configs), + _UniffiConverterOptionalString.lower(network), + _UniffiConverterOptionalTypeQuorumConfig.lower(quorum_config)) def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_free_eventquery, pointer) + _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_free_ledgerclient, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_clone_eventquery, self._pointer) - - # Used by alternative constructors or any methods which return this type. - @classmethod - def _make_instance_(cls, pointer): - # Lightly yucky way to bypass the usual __init__ logic - # and just create a new instance with the required pointer. - inst = cls.__new__(cls) - inst._pointer = pointer - return inst - -class _UniffiConverterTypeEventQuery: - - @staticmethod - def lift(value: int): - return EventQuery._make_instance_(value) - - @staticmethod - def check_lower(value: EventQuery): - if not isinstance(value, EventQuery): - raise TypeError("Expected EventQuery instance, {} found".format(type(value).__name__)) - - @staticmethod - def lower(value: EventQueryProtocol): - if not isinstance(value, EventQuery): - raise TypeError("Expected EventQuery instance, {} found".format(type(value).__name__)) - return value._uniffi_clone_pointer() - - @classmethod - def read(cls, buf: _UniffiRustBuffer): - ptr = buf.read_u64() - if ptr == 0: - raise InternalError("Raw pointer value was null") - return cls.lift(ptr) - - @classmethod - def write(cls, value: EventQueryProtocol, buf: _UniffiRustBuffer): - buf.write_u64(cls.lower(value)) - - - -class LedgerClientProtocol(typing.Protocol): - def get_receipt(self, hash: "bytes"): - raise NotImplementedError - def ping(self, ): - raise NotImplementedError - def query_events(self, query: "EventQuery"): - raise NotImplementedError - def submit_transaction(self, transaction: "Transaction"): - raise NotImplementedError - -class LedgerClient: - - _pointer: ctypes.c_void_p - def __init__(self, chain_id: "int",node_address: "str",contract_configs: "typing.List[ContractConfig]",network: "typing.Optional[str]",quorum_config: "typing.Optional[QuorumConfig]"): - _UniffiConverterUInt64.check_lower(chain_id) - - _UniffiConverterString.check_lower(node_address) - - _UniffiConverterSequenceTypeContractConfig.check_lower(contract_configs) - - _UniffiConverterOptionalString.check_lower(network) - - _UniffiConverterOptionalTypeQuorumConfig.check_lower(quorum_config) - - self._pointer = _rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_constructor_ledgerclient_new, - _UniffiConverterUInt64.lower(chain_id), - _UniffiConverterString.lower(node_address), - _UniffiConverterSequenceTypeContractConfig.lower(contract_configs), - _UniffiConverterOptionalString.lower(network), - _UniffiConverterOptionalTypeQuorumConfig.lower(quorum_config)) - - def __del__(self): - # In case of partial initialization of instances. - pointer = getattr(self, "_pointer", None) - if pointer is not None: - _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_free_ledgerclient, pointer) - - def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_clone_ledgerclient, self._pointer) + return _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_clone_ledgerclient, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2096,177 +1937,6 @@ def write(cls, value: LedgerClientProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) - -class TransactionProtocol(typing.Protocol): - def get_signing_bytes(self, ): - raise NotImplementedError - def set_signature(self, signature_data: "SignatureData"): - raise NotImplementedError - -class Transaction: - - _pointer: ctypes.c_void_p - def __init__(self, type: "TransactionType",_from: "typing.Optional[str]",to: "str",chain_id: "int",data: "bytes",nonce: "typing.Optional[int]",signature: "typing.Optional[TransactionSignature]"): - _UniffiConverterTypeTransactionType.check_lower(type) - - _UniffiConverterOptionalString.check_lower(_from) - - _UniffiConverterString.check_lower(to) - - _UniffiConverterUInt64.check_lower(chain_id) - - _UniffiConverterBytes.check_lower(data) - - _UniffiConverterOptionalUInt64.check_lower(nonce) - - _UniffiConverterOptionalTypeTransactionSignature.check_lower(signature) - - self._pointer = _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_constructor_transaction_new, - _UniffiConverterTypeTransactionType.lower(type), - _UniffiConverterOptionalString.lower(_from), - _UniffiConverterString.lower(to), - _UniffiConverterUInt64.lower(chain_id), - _UniffiConverterBytes.lower(data), - _UniffiConverterOptionalUInt64.lower(nonce), - _UniffiConverterOptionalTypeTransactionSignature.lower(signature)) - - def __del__(self): - # In case of partial initialization of instances. - pointer = getattr(self, "_pointer", None) - if pointer is not None: - _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_free_transaction, pointer) - - def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_clone_transaction, self._pointer) - - # Used by alternative constructors or any methods which return this type. - @classmethod - def _make_instance_(cls, pointer): - # Lightly yucky way to bypass the usual __init__ logic - # and just create a new instance with the required pointer. - inst = cls.__new__(cls) - inst._pointer = pointer - return inst - - - def get_signing_bytes(self, ) -> "bytes": - return _UniffiConverterBytes.lift( - _rust_call_with_error( - _UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_transaction_get_signing_bytes,self._uniffi_clone_pointer(),) - ) - - - - - - - def set_signature(self, signature_data: "SignatureData"): - _UniffiConverterTypeSignatureData.check_lower(signature_data) - - _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_transaction_set_signature,self._uniffi_clone_pointer(), - _UniffiConverterTypeSignatureData.lower(signature_data)) - - - - - - -class _UniffiConverterTypeTransaction: - - @staticmethod - def lift(value: int): - return Transaction._make_instance_(value) - - @staticmethod - def check_lower(value: Transaction): - if not isinstance(value, Transaction): - raise TypeError("Expected Transaction instance, {} found".format(type(value).__name__)) - - @staticmethod - def lower(value: TransactionProtocol): - if not isinstance(value, Transaction): - raise TypeError("Expected Transaction instance, {} found".format(type(value).__name__)) - return value._uniffi_clone_pointer() - - @classmethod - def read(cls, buf: _UniffiRustBuffer): - ptr = buf.read_u64() - if ptr == 0: - raise InternalError("Raw pointer value was null") - return cls.lift(ptr) - - @classmethod - def write(cls, value: TransactionProtocol, buf: _UniffiRustBuffer): - buf.write_u64(cls.lower(value)) - - - -class TransactionEndorsingDataProtocol(typing.Protocol): - def get_signing_bytes(self, ): - raise NotImplementedError - -class TransactionEndorsingData: - - _pointer: ctypes.c_void_p - - def __del__(self): - # In case of partial initialization of instances. - pointer = getattr(self, "_pointer", None) - if pointer is not None: - _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_free_transactionendorsingdata, pointer) - - def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_clone_transactionendorsingdata, self._pointer) - - # Used by alternative constructors or any methods which return this type. - @classmethod - def _make_instance_(cls, pointer): - # Lightly yucky way to bypass the usual __init__ logic - # and just create a new instance with the required pointer. - inst = cls.__new__(cls) - inst._pointer = pointer - return inst - - - def get_signing_bytes(self, ) -> "bytes": - return _UniffiConverterBytes.lift( - _rust_call_with_error( - _UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_method_transactionendorsingdata_get_signing_bytes,self._uniffi_clone_pointer(),) - ) - - - - - -class _UniffiConverterTypeTransactionEndorsingData: - - @staticmethod - def lift(value: int): - return TransactionEndorsingData._make_instance_(value) - - @staticmethod - def check_lower(value: TransactionEndorsingData): - if not isinstance(value, TransactionEndorsingData): - raise TypeError("Expected TransactionEndorsingData instance, {} found".format(type(value).__name__)) - - @staticmethod - def lower(value: TransactionEndorsingDataProtocol): - if not isinstance(value, TransactionEndorsingData): - raise TypeError("Expected TransactionEndorsingData instance, {} found".format(type(value).__name__)) - return value._uniffi_clone_pointer() - - @classmethod - def read(cls, buf: _UniffiRustBuffer): - ptr = buf.read_u64() - if ptr == 0: - raise InternalError("Raw pointer value was null") - return cls.lift(ptr) - - @classmethod - def write(cls, value: TransactionEndorsingDataProtocol, buf: _UniffiRustBuffer): - buf.write_u64(cls.lower(value)) - - class ContractConfig: address: "str" spec_path: "typing.Optional[str]" @@ -2348,6 +2018,64 @@ def write(value, buf): _UniffiConverterTypeJsonValue.write(value.abi, buf) +class CredentialDefinition: + issuer_id: "str" + schema_id: "str" + cred_def_type: "str" + tag: "str" + value: "JsonValue" + @typing.no_type_check + def __init__(self, issuer_id: "str", schema_id: "str", cred_def_type: "str", tag: "str", value: "JsonValue"): + self.issuer_id = issuer_id + self.schema_id = schema_id + self.cred_def_type = cred_def_type + self.tag = tag + self.value = value + + def __str__(self): + return "CredentialDefinition(issuer_id={}, schema_id={}, cred_def_type={}, tag={}, value={})".format(self.issuer_id, self.schema_id, self.cred_def_type, self.tag, self.value) + + def __eq__(self, other): + if self.issuer_id != other.issuer_id: + return False + if self.schema_id != other.schema_id: + return False + if self.cred_def_type != other.cred_def_type: + return False + if self.tag != other.tag: + return False + if self.value != other.value: + return False + return True + +class _UniffiConverterTypeCredentialDefinition(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return CredentialDefinition( + issuer_id=_UniffiConverterString.read(buf), + schema_id=_UniffiConverterString.read(buf), + cred_def_type=_UniffiConverterString.read(buf), + tag=_UniffiConverterString.read(buf), + value=_UniffiConverterTypeJsonValue.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiConverterString.check_lower(value.issuer_id) + _UniffiConverterString.check_lower(value.schema_id) + _UniffiConverterString.check_lower(value.cred_def_type) + _UniffiConverterString.check_lower(value.tag) + _UniffiConverterTypeJsonValue.check_lower(value.value) + + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value.issuer_id, buf) + _UniffiConverterString.write(value.schema_id, buf) + _UniffiConverterString.write(value.cred_def_type, buf) + _UniffiConverterString.write(value.tag, buf) + _UniffiConverterTypeJsonValue.write(value.value, buf) + + class DidAttributeChanged: identity: "str" name: "str" @@ -2589,6 +2317,64 @@ def write(value, buf): _UniffiConverterUInt64.write(value.block, buf) +class EventQuery: + address: "str" + from_block: "typing.Optional[int]" + to_block: "typing.Optional[int]" + event_signature: "typing.Optional[str]" + event_filter: "typing.Optional[str]" + @typing.no_type_check + def __init__(self, address: "str", from_block: "typing.Optional[int]", to_block: "typing.Optional[int]", event_signature: "typing.Optional[str]", event_filter: "typing.Optional[str]"): + self.address = address + self.from_block = from_block + self.to_block = to_block + self.event_signature = event_signature + self.event_filter = event_filter + + def __str__(self): + return "EventQuery(address={}, from_block={}, to_block={}, event_signature={}, event_filter={})".format(self.address, self.from_block, self.to_block, self.event_signature, self.event_filter) + + def __eq__(self, other): + if self.address != other.address: + return False + if self.from_block != other.from_block: + return False + if self.to_block != other.to_block: + return False + if self.event_signature != other.event_signature: + return False + if self.event_filter != other.event_filter: + return False + return True + +class _UniffiConverterTypeEventQuery(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return EventQuery( + address=_UniffiConverterString.read(buf), + from_block=_UniffiConverterOptionalUInt64.read(buf), + to_block=_UniffiConverterOptionalUInt64.read(buf), + event_signature=_UniffiConverterOptionalString.read(buf), + event_filter=_UniffiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiConverterString.check_lower(value.address) + _UniffiConverterOptionalUInt64.check_lower(value.from_block) + _UniffiConverterOptionalUInt64.check_lower(value.to_block) + _UniffiConverterOptionalString.check_lower(value.event_signature) + _UniffiConverterOptionalString.check_lower(value.event_filter) + + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value.address, buf) + _UniffiConverterOptionalUInt64.write(value.from_block, buf) + _UniffiConverterOptionalUInt64.write(value.to_block, buf) + _UniffiConverterOptionalString.write(value.event_signature, buf) + _UniffiConverterOptionalString.write(value.event_filter, buf) + + class PingStatus: status: "Status" @typing.no_type_check @@ -2670,6 +2456,57 @@ def write(value, buf): _UniffiConverterOptionalUInt64.write(value.retry_interval, buf) +class Schema: + issuer_id: "str" + name: "str" + version: "str" + attr_names: "typing.List[str]" + @typing.no_type_check + def __init__(self, issuer_id: "str", name: "str", version: "str", attr_names: "typing.List[str]"): + self.issuer_id = issuer_id + self.name = name + self.version = version + self.attr_names = attr_names + + def __str__(self): + return "Schema(issuer_id={}, name={}, version={}, attr_names={})".format(self.issuer_id, self.name, self.version, self.attr_names) + + def __eq__(self, other): + if self.issuer_id != other.issuer_id: + return False + if self.name != other.name: + return False + if self.version != other.version: + return False + if self.attr_names != other.attr_names: + return False + return True + +class _UniffiConverterTypeSchema(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Schema( + issuer_id=_UniffiConverterString.read(buf), + name=_UniffiConverterString.read(buf), + version=_UniffiConverterString.read(buf), + attr_names=_UniffiConverterSequenceString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiConverterString.check_lower(value.issuer_id) + _UniffiConverterString.check_lower(value.name) + _UniffiConverterString.check_lower(value.version) + _UniffiConverterSequenceString.check_lower(value.attr_names) + + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value.issuer_id, buf) + _UniffiConverterString.write(value.name, buf) + _UniffiConverterString.write(value.version, buf) + _UniffiConverterSequenceString.write(value.attr_names, buf) + + class SignatureData: recovery_id: "int" signature: "bytes" @@ -2707,48 +2544,162 @@ def write(value, buf): _UniffiConverterBytes.write(value.signature, buf) -class TransactionSignature: - v: "int" - r: "bytes" - s: "bytes" +class Transaction: + type: "TransactionType" + _from: "typing.Optional[str]" + to: "str" + nonce: "typing.Optional[int]" + chain_id: "int" + data: "bytes" + signature: "typing.Optional[SignatureData]" + hash: "typing.Optional[bytes]" + @typing.no_type_check + def __init__(self, type: "TransactionType", _from: "typing.Optional[str]", to: "str", nonce: "typing.Optional[int]", chain_id: "int", data: "bytes", signature: "typing.Optional[SignatureData]", hash: "typing.Optional[bytes]"): + self.type = type + self._from = _from + self.to = to + self.nonce = nonce + self.chain_id = chain_id + self.data = data + self.signature = signature + self.hash = hash + + def __str__(self): + return "Transaction(type={}, _from={}, to={}, nonce={}, chain_id={}, data={}, signature={}, hash={})".format(self.type, self._from, self.to, self.nonce, self.chain_id, self.data, self.signature, self.hash) + + def __eq__(self, other): + if self.type != other.type: + return False + if self._from != other._from: + return False + if self.to != other.to: + return False + if self.nonce != other.nonce: + return False + if self.chain_id != other.chain_id: + return False + if self.data != other.data: + return False + if self.signature != other.signature: + return False + if self.hash != other.hash: + return False + return True + +class _UniffiConverterTypeTransaction(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return Transaction( + type=_UniffiConverterTypeTransactionType.read(buf), + _from=_UniffiConverterOptionalString.read(buf), + to=_UniffiConverterString.read(buf), + nonce=_UniffiConverterOptionalUInt64.read(buf), + chain_id=_UniffiConverterUInt64.read(buf), + data=_UniffiConverterBytes.read(buf), + signature=_UniffiConverterOptionalTypeSignatureData.read(buf), + hash=_UniffiConverterOptionalBytes.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiConverterTypeTransactionType.check_lower(value.type) + _UniffiConverterOptionalString.check_lower(value._from) + _UniffiConverterString.check_lower(value.to) + _UniffiConverterOptionalUInt64.check_lower(value.nonce) + _UniffiConverterUInt64.check_lower(value.chain_id) + _UniffiConverterBytes.check_lower(value.data) + _UniffiConverterOptionalTypeSignatureData.check_lower(value.signature) + _UniffiConverterOptionalBytes.check_lower(value.hash) + + @staticmethod + def write(value, buf): + _UniffiConverterTypeTransactionType.write(value.type, buf) + _UniffiConverterOptionalString.write(value._from, buf) + _UniffiConverterString.write(value.to, buf) + _UniffiConverterOptionalUInt64.write(value.nonce, buf) + _UniffiConverterUInt64.write(value.chain_id, buf) + _UniffiConverterBytes.write(value.data, buf) + _UniffiConverterOptionalTypeSignatureData.write(value.signature, buf) + _UniffiConverterOptionalBytes.write(value.hash, buf) + + +class TransactionEndorsingData: + to: "str" + _from: "str" + nonce: "typing.Optional[int]" + contract: "str" + method: "str" + endorsing_method: "str" + params: "typing.List[JsonValue]" + signature: "typing.Optional[SignatureData]" @typing.no_type_check - def __init__(self, v: "int", r: "bytes", s: "bytes"): - self.v = v - self.r = r - self.s = s + def __init__(self, to: "str", _from: "str", nonce: "typing.Optional[int]", contract: "str", method: "str", endorsing_method: "str", params: "typing.List[JsonValue]", signature: "typing.Optional[SignatureData]"): + self.to = to + self._from = _from + self.nonce = nonce + self.contract = contract + self.method = method + self.endorsing_method = endorsing_method + self.params = params + self.signature = signature def __str__(self): - return "TransactionSignature(v={}, r={}, s={})".format(self.v, self.r, self.s) + return "TransactionEndorsingData(to={}, _from={}, nonce={}, contract={}, method={}, endorsing_method={}, params={}, signature={})".format(self.to, self._from, self.nonce, self.contract, self.method, self.endorsing_method, self.params, self.signature) def __eq__(self, other): - if self.v != other.v: + if self.to != other.to: + return False + if self._from != other._from: + return False + if self.nonce != other.nonce: return False - if self.r != other.r: + if self.contract != other.contract: return False - if self.s != other.s: + if self.method != other.method: + return False + if self.endorsing_method != other.endorsing_method: + return False + if self.params != other.params: + return False + if self.signature != other.signature: return False return True -class _UniffiConverterTypeTransactionSignature(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTransactionEndorsingData(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TransactionSignature( - v=_UniffiConverterUInt64.read(buf), - r=_UniffiConverterBytes.read(buf), - s=_UniffiConverterBytes.read(buf), + return TransactionEndorsingData( + to=_UniffiConverterString.read(buf), + _from=_UniffiConverterString.read(buf), + nonce=_UniffiConverterOptionalUInt64.read(buf), + contract=_UniffiConverterString.read(buf), + method=_UniffiConverterString.read(buf), + endorsing_method=_UniffiConverterString.read(buf), + params=_UniffiConverterSequenceTypeJsonValue.read(buf), + signature=_UniffiConverterOptionalTypeSignatureData.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterUInt64.check_lower(value.v) - _UniffiConverterBytes.check_lower(value.r) - _UniffiConverterBytes.check_lower(value.s) + _UniffiConverterString.check_lower(value.to) + _UniffiConverterString.check_lower(value._from) + _UniffiConverterOptionalUInt64.check_lower(value.nonce) + _UniffiConverterString.check_lower(value.contract) + _UniffiConverterString.check_lower(value.method) + _UniffiConverterString.check_lower(value.endorsing_method) + _UniffiConverterSequenceTypeJsonValue.check_lower(value.params) + _UniffiConverterOptionalTypeSignatureData.check_lower(value.signature) @staticmethod def write(value, buf): - _UniffiConverterUInt64.write(value.v, buf) - _UniffiConverterBytes.write(value.r, buf) - _UniffiConverterBytes.write(value.s, buf) + _UniffiConverterString.write(value.to, buf) + _UniffiConverterString.write(value._from, buf) + _UniffiConverterOptionalUInt64.write(value.nonce, buf) + _UniffiConverterString.write(value.contract, buf) + _UniffiConverterString.write(value.method, buf) + _UniffiConverterString.write(value.endorsing_method, buf) + _UniffiConverterSequenceTypeJsonValue.write(value.params, buf) + _UniffiConverterOptionalTypeSignatureData.write(value.signature, buf) @@ -3051,6 +3002,16 @@ def __init__(self, msg): def __repr__(self): return "VdrError.ClientInvalidTransaction({})".format(str(self)) _UniffiTempVdrError.ClientInvalidTransaction = ClientInvalidTransaction # type: ignore + class ClientInvalidEndorsementData(_UniffiTempVdrError): + + def __init__(self, msg): + super().__init__(", ".join([ + "msg={!r}".format(msg), + ])) + self.msg = msg + def __repr__(self): + return "VdrError.ClientInvalidEndorsementData({})".format(str(self)) + _UniffiTempVdrError.ClientInvalidEndorsementData = ClientInvalidEndorsementData # type: ignore class ClientInvalidResponse(_UniffiTempVdrError): def __init__(self, msg): @@ -3229,67 +3190,71 @@ def read(buf): msg=_UniffiConverterString.read(buf), ) if variant == 3: - return VdrError.ClientInvalidResponse( + return VdrError.ClientInvalidEndorsementData( msg=_UniffiConverterString.read(buf), ) if variant == 4: - return VdrError.ClientTransactionReverted( + return VdrError.ClientInvalidResponse( msg=_UniffiConverterString.read(buf), ) if variant == 5: - return VdrError.ClientUnexpectedError( + return VdrError.ClientTransactionReverted( msg=_UniffiConverterString.read(buf), ) if variant == 6: - return VdrError.ClientInvalidState( + return VdrError.ClientUnexpectedError( msg=_UniffiConverterString.read(buf), ) if variant == 7: - return VdrError.ContractInvalidName( + return VdrError.ClientInvalidState( msg=_UniffiConverterString.read(buf), ) if variant == 8: - return VdrError.ContractInvalidSpec( + return VdrError.ContractInvalidName( msg=_UniffiConverterString.read(buf), ) if variant == 9: - return VdrError.ContractInvalidInputData( + return VdrError.ContractInvalidSpec( + msg=_UniffiConverterString.read(buf), ) if variant == 10: + return VdrError.ContractInvalidInputData( + ) + if variant == 11: return VdrError.ContractInvalidResponseData( msg=_UniffiConverterString.read(buf), ) - if variant == 11: + if variant == 12: return VdrError.SignerInvalidPrivateKey( ) - if variant == 12: + if variant == 13: return VdrError.SignerInvalidMessage( ) - if variant == 13: + if variant == 14: return VdrError.SignerMissingKey( msg=_UniffiConverterString.read(buf), ) - if variant == 14: + if variant == 15: return VdrError.SignerUnexpectedError( msg=_UniffiConverterString.read(buf), ) - if variant == 15: + if variant == 16: return VdrError.CommonInvalidData( msg=_UniffiConverterString.read(buf), ) - if variant == 16: + if variant == 17: return VdrError.QuorumNotReached( msg=_UniffiConverterString.read(buf), ) - if variant == 17: + if variant == 18: return VdrError.GetTransactionError( msg=_UniffiConverterString.read(buf), ) - if variant == 18: + if variant == 19: return VdrError.InvalidSchema( msg=_UniffiConverterString.read(buf), ) - if variant == 19: + if variant == 20: return VdrError.InvalidCredentialDefinition( msg=_UniffiConverterString.read(buf), ) @@ -3302,6 +3267,9 @@ def check_lower(value): if isinstance(value, VdrError.ClientInvalidTransaction): _UniffiConverterString.check_lower(value.msg) return + if isinstance(value, VdrError.ClientInvalidEndorsementData): + _UniffiConverterString.check_lower(value.msg) + return if isinstance(value, VdrError.ClientInvalidResponse): _UniffiConverterString.check_lower(value.msg) return @@ -3358,53 +3326,56 @@ def write(value, buf): if isinstance(value, VdrError.ClientInvalidTransaction): buf.write_i32(2) _UniffiConverterString.write(value.msg, buf) - if isinstance(value, VdrError.ClientInvalidResponse): + if isinstance(value, VdrError.ClientInvalidEndorsementData): buf.write_i32(3) _UniffiConverterString.write(value.msg, buf) - if isinstance(value, VdrError.ClientTransactionReverted): + if isinstance(value, VdrError.ClientInvalidResponse): buf.write_i32(4) _UniffiConverterString.write(value.msg, buf) - if isinstance(value, VdrError.ClientUnexpectedError): + if isinstance(value, VdrError.ClientTransactionReverted): buf.write_i32(5) _UniffiConverterString.write(value.msg, buf) - if isinstance(value, VdrError.ClientInvalidState): + if isinstance(value, VdrError.ClientUnexpectedError): buf.write_i32(6) _UniffiConverterString.write(value.msg, buf) - if isinstance(value, VdrError.ContractInvalidName): + if isinstance(value, VdrError.ClientInvalidState): buf.write_i32(7) _UniffiConverterString.write(value.msg, buf) - if isinstance(value, VdrError.ContractInvalidSpec): + if isinstance(value, VdrError.ContractInvalidName): buf.write_i32(8) _UniffiConverterString.write(value.msg, buf) + if isinstance(value, VdrError.ContractInvalidSpec): + buf.write_i32(9) + _UniffiConverterString.write(value.msg, buf) if isinstance(value, VdrError.ContractInvalidInputData): - buf.write_i32(9) - if isinstance(value, VdrError.ContractInvalidResponseData): buf.write_i32(10) + if isinstance(value, VdrError.ContractInvalidResponseData): + buf.write_i32(11) _UniffiConverterString.write(value.msg, buf) if isinstance(value, VdrError.SignerInvalidPrivateKey): - buf.write_i32(11) - if isinstance(value, VdrError.SignerInvalidMessage): buf.write_i32(12) - if isinstance(value, VdrError.SignerMissingKey): + if isinstance(value, VdrError.SignerInvalidMessage): buf.write_i32(13) + if isinstance(value, VdrError.SignerMissingKey): + buf.write_i32(14) _UniffiConverterString.write(value.msg, buf) if isinstance(value, VdrError.SignerUnexpectedError): - buf.write_i32(14) + buf.write_i32(15) _UniffiConverterString.write(value.msg, buf) if isinstance(value, VdrError.CommonInvalidData): - buf.write_i32(15) + buf.write_i32(16) _UniffiConverterString.write(value.msg, buf) if isinstance(value, VdrError.QuorumNotReached): - buf.write_i32(16) + buf.write_i32(17) _UniffiConverterString.write(value.msg, buf) if isinstance(value, VdrError.GetTransactionError): - buf.write_i32(17) + buf.write_i32(18) _UniffiConverterString.write(value.msg, buf) if isinstance(value, VdrError.InvalidSchema): - buf.write_i32(18) + buf.write_i32(19) _UniffiConverterString.write(value.msg, buf) if isinstance(value, VdrError.InvalidCredentialDefinition): - buf.write_i32(19) + buf.write_i32(20) _UniffiConverterString.write(value.msg, buf) @@ -3490,6 +3461,33 @@ def read(cls, buf): +class _UniffiConverterOptionalBytes(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterBytes.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiConverterBytes.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterBytes.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + + + class _UniffiConverterOptionalTypeContractSpec(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -3571,11 +3569,11 @@ def read(cls, buf): -class _UniffiConverterOptionalTypeTransactionSignature(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeSignatureData(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeTransactionSignature.check_lower(value) + _UniffiConverterTypeSignatureData.check_lower(value) @classmethod def write(cls, value, buf): @@ -3584,7 +3582,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeTransactionSignature.write(value, buf) + _UniffiConverterTypeSignatureData.write(value, buf) @classmethod def read(cls, buf): @@ -3592,7 +3590,7 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeTransactionSignature.read(buf) + return _UniffiConverterTypeSignatureData.read(buf) else: raise InternalError("Unexpected flag byte for optional type") @@ -3697,6 +3695,31 @@ def read(cls, buf): ] + +class _UniffiConverterSequenceTypeJsonValue(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiConverterTypeJsonValue.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeJsonValue.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeJsonValue.read(buf) for i in range(count) + ] + + # Type alias JsonValue = str @@ -3733,9 +3756,9 @@ def build_add_validator_transaction(client: "LedgerClient",_from: "str",validato _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(_from), _UniffiConverterString.lower(validator_address)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -3757,9 +3780,9 @@ def build_assign_role_transaction(client: "LedgerClient",_from: "str",role: "int _UniffiConverterString.lower(_from), _UniffiConverterUInt8.lower(role), _UniffiConverterString.lower(account)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -3775,54 +3798,30 @@ def build_create_credential_definition_endorsing_data(client: "LedgerClient",cre _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_credential_definition_endorsing_data( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(credential_definition)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransactionEndorsingData.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_create_credential_definition_signed_transaction(client: "LedgerClient",_from: "str",credential_definition: "str",signature: "SignatureData"): - _UniffiConverterTypeLedgerClient.check_lower(client) - - _UniffiConverterString.check_lower(_from) - - _UniffiConverterString.check_lower(credential_definition) - - _UniffiConverterTypeSignatureData.check_lower(signature) - - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_credential_definition_signed_transaction( - _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(_from), - _UniffiConverterString.lower(credential_definition), - _UniffiConverterTypeSignatureData.lower(signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransaction.lift, - # Error FFI converter - _UniffiConverterTypeVdrError, - ) - -def build_create_credential_definition_transaction(client: "LedgerClient",_from: "str",credential_definition: "str"): +def build_create_credential_definition_transaction(client: "LedgerClient",_from: "str",credential_definition: "CredentialDefinition"): _UniffiConverterTypeLedgerClient.check_lower(client) _UniffiConverterString.check_lower(_from) - _UniffiConverterString.check_lower(credential_definition) + _UniffiConverterTypeCredentialDefinition.check_lower(credential_definition) return _uniffi_rust_call_async( _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_credential_definition_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(_from), - _UniffiConverterString.lower(credential_definition)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiConverterTypeCredentialDefinition.lower(credential_definition)), + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -3841,9 +3840,9 @@ def build_create_did_endorsing_data(client: "LedgerClient",did: "str",did_doc: " _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(did), _UniffiConverterString.lower(did_doc)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransactionEndorsingData.lift, # Error FFI converter @@ -3868,48 +3867,15 @@ def build_create_did_mapping_endorsing_data(client: "LedgerClient",did: "str",le _UniffiConverterString.lower(legacy_identifier), _UniffiConverterString.lower(legacy_verkey), _UniffiConverterBytes.lower(ed25519_signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransactionEndorsingData.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_create_did_mapping_signed_transaction(client: "LedgerClient",_from: "str",did: "str",legacy_identifier: "str",legacy_verkey: "str",ed25519_signature: "bytes",signature: "SignatureData"): - _UniffiConverterTypeLedgerClient.check_lower(client) - - _UniffiConverterString.check_lower(_from) - - _UniffiConverterString.check_lower(did) - - _UniffiConverterString.check_lower(legacy_identifier) - - _UniffiConverterString.check_lower(legacy_verkey) - - _UniffiConverterBytes.check_lower(ed25519_signature) - - _UniffiConverterTypeSignatureData.check_lower(signature) - - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_did_mapping_signed_transaction( - _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(_from), - _UniffiConverterString.lower(did), - _UniffiConverterString.lower(legacy_identifier), - _UniffiConverterString.lower(legacy_verkey), - _UniffiConverterBytes.lower(ed25519_signature), - _UniffiConverterTypeSignatureData.lower(signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransaction.lift, - # Error FFI converter - _UniffiConverterTypeVdrError, - ) - def build_create_did_mapping_transaction(client: "LedgerClient",_from: "str",did: "str",legacy_identifier: "str",legacy_verkey: "str",ed25519_signature: "bytes"): _UniffiConverterTypeLedgerClient.check_lower(client) @@ -3931,60 +3897,33 @@ def build_create_did_mapping_transaction(client: "LedgerClient",_from: "str",did _UniffiConverterString.lower(legacy_identifier), _UniffiConverterString.lower(legacy_verkey), _UniffiConverterBytes.lower(ed25519_signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransaction.lift, - # Error FFI converter - _UniffiConverterTypeVdrError, - ) - -def build_create_did_signed_transaction(client: "LedgerClient",_from: "str",did: "str",did_doc: "str",signature: "SignatureData"): - _UniffiConverterTypeLedgerClient.check_lower(client) - - _UniffiConverterString.check_lower(_from) - - _UniffiConverterString.check_lower(did) - - _UniffiConverterString.check_lower(did_doc) - - _UniffiConverterTypeSignatureData.check_lower(signature) - - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_did_signed_transaction( - _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(_from), - _UniffiConverterString.lower(did), - _UniffiConverterString.lower(did_doc), - _UniffiConverterTypeSignatureData.lower(signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_create_did_transaction(client: "LedgerClient",_from: "str",did: "str",did_doc: "str"): +def build_create_did_transaction(client: "LedgerClient",_from: "str",did: "str",did_doc: "JsonValue"): _UniffiConverterTypeLedgerClient.check_lower(client) _UniffiConverterString.check_lower(_from) _UniffiConverterString.check_lower(did) - _UniffiConverterString.check_lower(did_doc) + _UniffiConverterTypeJsonValue.check_lower(did_doc) return _uniffi_rust_call_async( _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_did_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(_from), _UniffiConverterString.lower(did), - _UniffiConverterString.lower(did_doc)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiConverterTypeJsonValue.lower(did_doc)), + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4009,48 +3948,15 @@ def build_create_resource_mapping_endorsing_data(client: "LedgerClient",did: "st _UniffiConverterString.lower(legacy_issuer_identifier), _UniffiConverterString.lower(legacy_identifier), _UniffiConverterString.lower(new_identifier)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransactionEndorsingData.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_create_resource_mapping_signed_transaction(client: "LedgerClient",_from: "str",did: "str",legacy_issuer_identifier: "str",legacy_identifier: "str",new_identifier: "str",signature: "SignatureData"): - _UniffiConverterTypeLedgerClient.check_lower(client) - - _UniffiConverterString.check_lower(_from) - - _UniffiConverterString.check_lower(did) - - _UniffiConverterString.check_lower(legacy_issuer_identifier) - - _UniffiConverterString.check_lower(legacy_identifier) - - _UniffiConverterString.check_lower(new_identifier) - - _UniffiConverterTypeSignatureData.check_lower(signature) - - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_resource_mapping_signed_transaction( - _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(_from), - _UniffiConverterString.lower(did), - _UniffiConverterString.lower(legacy_issuer_identifier), - _UniffiConverterString.lower(legacy_identifier), - _UniffiConverterString.lower(new_identifier), - _UniffiConverterTypeSignatureData.lower(signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransaction.lift, - # Error FFI converter - _UniffiConverterTypeVdrError, - ) - def build_create_resource_mapping_transaction(client: "LedgerClient",_from: "str",did: "str",legacy_issuer_identifier: "str",legacy_identifier: "str",new_identifier: "str"): _UniffiConverterTypeLedgerClient.check_lower(client) @@ -4072,57 +3978,33 @@ def build_create_resource_mapping_transaction(client: "LedgerClient",_from: "str _UniffiConverterString.lower(legacy_issuer_identifier), _UniffiConverterString.lower(legacy_identifier), _UniffiConverterString.lower(new_identifier)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_create_schema_endorsing_data(client: "LedgerClient",schema: "str"): +def build_create_schema_endorsing_data(client: "LedgerClient",schema: "Schema"): _UniffiConverterTypeLedgerClient.check_lower(client) - _UniffiConverterString.check_lower(schema) + _UniffiConverterTypeSchema.check_lower(schema) return _uniffi_rust_call_async( _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_schema_endorsing_data( _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(schema)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiConverterTypeSchema.lower(schema)), + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransactionEndorsingData.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_create_schema_signed_transaction(client: "LedgerClient",_from: "str",schema: "str",signature: "SignatureData"): - _UniffiConverterTypeLedgerClient.check_lower(client) - - _UniffiConverterString.check_lower(_from) - - _UniffiConverterString.check_lower(schema) - - _UniffiConverterTypeSignatureData.check_lower(signature) - - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_create_schema_signed_transaction( - _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(_from), - _UniffiConverterString.lower(schema), - _UniffiConverterTypeSignatureData.lower(signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransaction.lift, - # Error FFI converter - _UniffiConverterTypeVdrError, - ) - def build_create_schema_transaction(client: "LedgerClient",_from: "str",schema: "str"): _UniffiConverterTypeLedgerClient.check_lower(client) @@ -4135,9 +4017,9 @@ def build_create_schema_transaction(client: "LedgerClient",_from: "str",schema: _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(_from), _UniffiConverterString.lower(schema)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4153,39 +4035,15 @@ def build_deactivate_did_endorsing_data(client: "LedgerClient",did: "str"): _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_deactivate_did_endorsing_data( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(did)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransactionEndorsingData.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_deactivate_did_signed_transaction(client: "LedgerClient",_from: "str",did: "str",signature: "SignatureData"): - _UniffiConverterTypeLedgerClient.check_lower(client) - - _UniffiConverterString.check_lower(_from) - - _UniffiConverterString.check_lower(did) - - _UniffiConverterTypeSignatureData.check_lower(signature) - - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_deactivate_did_signed_transaction( - _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(_from), - _UniffiConverterString.lower(did), - _UniffiConverterTypeSignatureData.lower(signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransaction.lift, - # Error FFI converter - _UniffiConverterTypeVdrError, - ) - def build_deactivate_did_transaction(client: "LedgerClient",_from: "str",did: "str"): _UniffiConverterTypeLedgerClient.check_lower(client) @@ -4198,47 +4056,18 @@ def build_deactivate_did_transaction(client: "LedgerClient",_from: "str",did: "s _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(_from), _UniffiConverterString.lower(did)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransaction.lift, - # Error FFI converter - _UniffiConverterTypeVdrError, - ) - -def build_did_add_delegate_endorsing_data(client: "LedgerClient",did: "str",delegate_type: "str",delegate: "str",validity: "int"): - _UniffiConverterTypeLedgerClient.check_lower(client) - - _UniffiConverterString.check_lower(did) - - _UniffiConverterString.check_lower(delegate_type) - - _UniffiConverterString.check_lower(delegate) - - _UniffiConverterUInt64.check_lower(validity) - - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_add_delegate_endorsing_data( - _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(did), - _UniffiConverterString.lower(delegate_type), - _UniffiConverterString.lower(delegate), - _UniffiConverterUInt64.lower(validity)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeTransactionEndorsingData.lift, + _UniffiConverterTypeTransaction.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_did_add_delegate_signed_transaction(client: "LedgerClient",_from: "str",did: "str",delegate_type: "str",delegate: "str",validity: "int",signature: "SignatureData"): +def build_did_add_delegate_endorsing_data(client: "LedgerClient",did: "str",delegate_type: "str",delegate: "str",validity: "int"): _UniffiConverterTypeLedgerClient.check_lower(client) - _UniffiConverterString.check_lower(_from) - _UniffiConverterString.check_lower(did) _UniffiConverterString.check_lower(delegate_type) @@ -4247,22 +4076,18 @@ def build_did_add_delegate_signed_transaction(client: "LedgerClient",_from: "str _UniffiConverterUInt64.check_lower(validity) - _UniffiConverterTypeSignatureData.check_lower(signature) - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_add_delegate_signed_transaction( + _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_add_delegate_endorsing_data( _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(_from), _UniffiConverterString.lower(did), _UniffiConverterString.lower(delegate_type), _UniffiConverterString.lower(delegate), - _UniffiConverterUInt64.lower(validity), - _UniffiConverterTypeSignatureData.lower(signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiConverterUInt64.lower(validity)), + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeTransaction.lift, + _UniffiConverterTypeTransactionEndorsingData.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) @@ -4288,9 +4113,9 @@ def build_did_add_delegate_transaction(client: "LedgerClient",_from: "str",did: _UniffiConverterString.lower(delegate_type), _UniffiConverterString.lower(delegate), _UniffiConverterUInt64.lower(validity)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4309,42 +4134,15 @@ def build_did_change_owner_endorsing_data(client: "LedgerClient",did: "str",new_ _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(did), _UniffiConverterString.lower(new_owner)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransactionEndorsingData.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_did_change_owner_signed_transaction(client: "LedgerClient",_from: "str",did: "str",new_owner: "str",signature: "SignatureData"): - _UniffiConverterTypeLedgerClient.check_lower(client) - - _UniffiConverterString.check_lower(_from) - - _UniffiConverterString.check_lower(did) - - _UniffiConverterString.check_lower(new_owner) - - _UniffiConverterTypeSignatureData.check_lower(signature) - - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_change_owner_signed_transaction( - _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(_from), - _UniffiConverterString.lower(did), - _UniffiConverterString.lower(new_owner), - _UniffiConverterTypeSignatureData.lower(signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransaction.lift, - # Error FFI converter - _UniffiConverterTypeVdrError, - ) - def build_did_change_owner_transaction(client: "LedgerClient",_from: "str",did: "str",new_owner: "str"): _UniffiConverterTypeLedgerClient.check_lower(client) @@ -4360,9 +4158,9 @@ def build_did_change_owner_transaction(client: "LedgerClient",_from: "str",did: _UniffiConverterString.lower(_from), _UniffiConverterString.lower(did), _UniffiConverterString.lower(new_owner)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4381,42 +4179,15 @@ def build_did_revoke_attribute_endorsing_data(client: "LedgerClient",did: "str", _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(did), _UniffiConverterString.lower(attribute)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransactionEndorsingData.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_did_revoke_attribute_signed_transaction(client: "LedgerClient",_from: "str",did: "str",attribute: "str",signature: "SignatureData"): - _UniffiConverterTypeLedgerClient.check_lower(client) - - _UniffiConverterString.check_lower(_from) - - _UniffiConverterString.check_lower(did) - - _UniffiConverterString.check_lower(attribute) - - _UniffiConverterTypeSignatureData.check_lower(signature) - - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_revoke_attribute_signed_transaction( - _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(_from), - _UniffiConverterString.lower(did), - _UniffiConverterString.lower(attribute), - _UniffiConverterTypeSignatureData.lower(signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransaction.lift, - # Error FFI converter - _UniffiConverterTypeVdrError, - ) - def build_did_revoke_attribute_transaction(client: "LedgerClient",_from: "str",did: "str",attribute: "str"): _UniffiConverterTypeLedgerClient.check_lower(client) @@ -4432,9 +4203,9 @@ def build_did_revoke_attribute_transaction(client: "LedgerClient",_from: "str",d _UniffiConverterString.lower(_from), _UniffiConverterString.lower(did), _UniffiConverterString.lower(attribute)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4456,45 +4227,15 @@ def build_did_revoke_delegate_endorsing_data(client: "LedgerClient",did: "str",d _UniffiConverterString.lower(did), _UniffiConverterString.lower(delegate_type), _UniffiConverterString.lower(delegate)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransactionEndorsingData.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_did_revoke_delegate_signed_transaction(client: "LedgerClient",_from: "str",did: "str",delegate_type: "str",delegate: "str",signature: "SignatureData"): - _UniffiConverterTypeLedgerClient.check_lower(client) - - _UniffiConverterString.check_lower(_from) - - _UniffiConverterString.check_lower(did) - - _UniffiConverterString.check_lower(delegate_type) - - _UniffiConverterString.check_lower(delegate) - - _UniffiConverterTypeSignatureData.check_lower(signature) - - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_revoke_delegate_signed_transaction( - _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(_from), - _UniffiConverterString.lower(did), - _UniffiConverterString.lower(delegate_type), - _UniffiConverterString.lower(delegate), - _UniffiConverterTypeSignatureData.lower(signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransaction.lift, - # Error FFI converter - _UniffiConverterTypeVdrError, - ) - def build_did_revoke_delegate_transaction(client: "LedgerClient",_from: "str",did: "str",delegate_type: "str",delegate: "str"): _UniffiConverterTypeLedgerClient.check_lower(client) @@ -4513,9 +4254,9 @@ def build_did_revoke_delegate_transaction(client: "LedgerClient",_from: "str",di _UniffiConverterString.lower(did), _UniffiConverterString.lower(delegate_type), _UniffiConverterString.lower(delegate)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4537,16 +4278,16 @@ def build_did_set_attribute_endorsing_data(client: "LedgerClient",did: "str",att _UniffiConverterString.lower(did), _UniffiConverterString.lower(attribute), _UniffiConverterUInt64.lower(validity)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransactionEndorsingData.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_did_set_attribute_signed_transaction(client: "LedgerClient",_from: "str",did: "str",attribute: "str",validity: "int",signature: "SignatureData"): +def build_did_set_attribute_transaction(client: "LedgerClient",_from: "str",did: "str",attribute: "str",validity: "int"): _UniffiConverterTypeLedgerClient.check_lower(client) _UniffiConverterString.check_lower(_from) @@ -4557,46 +4298,37 @@ def build_did_set_attribute_signed_transaction(client: "LedgerClient",_from: "st _UniffiConverterUInt64.check_lower(validity) - _UniffiConverterTypeSignatureData.check_lower(signature) - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_set_attribute_signed_transaction( + _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_set_attribute_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(_from), _UniffiConverterString.lower(did), _UniffiConverterString.lower(attribute), - _UniffiConverterUInt64.lower(validity), - _UniffiConverterTypeSignatureData.lower(signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiConverterUInt64.lower(validity)), + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_did_set_attribute_transaction(client: "LedgerClient",_from: "str",did: "str",attribute: "str",validity: "int"): +def build_endorsement_transaction(client: "LedgerClient",_from: "str",endorsing_data: "TransactionEndorsingData"): _UniffiConverterTypeLedgerClient.check_lower(client) _UniffiConverterString.check_lower(_from) - _UniffiConverterString.check_lower(did) - - _UniffiConverterString.check_lower(attribute) - - _UniffiConverterUInt64.check_lower(validity) + _UniffiConverterTypeTransactionEndorsingData.check_lower(endorsing_data) return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_did_set_attribute_transaction( + _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_endorsement_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(_from), - _UniffiConverterString.lower(did), - _UniffiConverterString.lower(attribute), - _UniffiConverterUInt64.lower(validity)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiConverterTypeTransactionEndorsingData.lower(endorsing_data)), + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4612,9 +4344,9 @@ def build_get_did_changed_transaction(client: "LedgerClient",did: "str"): _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_get_did_changed_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(did)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4636,9 +4368,9 @@ def build_get_did_events_query(client: "LedgerClient",did: "str",from_block: "ty _UniffiConverterString.lower(did), _UniffiConverterOptionalUInt64.lower(from_block), _UniffiConverterOptionalUInt64.lower(to_block)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeEventQuery.lift, # Error FFI converter @@ -4654,9 +4386,9 @@ def build_get_did_mapping_transaction(client: "LedgerClient",legacy_identifier: _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_get_did_mapping_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(legacy_identifier)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4672,9 +4404,9 @@ def build_get_did_owner_transaction(client: "LedgerClient",did: "str"): _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_get_did_owner_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(did)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4690,9 +4422,9 @@ def build_get_identity_nonce_transaction(client: "LedgerClient",identity: "str") _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_get_identity_nonce_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(identity)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4708,9 +4440,9 @@ def build_get_resource_mapping_transaction(client: "LedgerClient",legacy_identif _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_get_resource_mapping_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(legacy_identifier)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4726,9 +4458,9 @@ def build_get_role_transaction(client: "LedgerClient",account: "str"): _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_get_role_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(account)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4741,9 +4473,9 @@ def build_get_validators_transaction(client: "LedgerClient"): return _uniffi_rust_call_async( _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_get_validators_transaction( _UniffiConverterTypeLedgerClient.lower(client)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4762,9 +4494,9 @@ def build_has_role_transaction(client: "LedgerClient",role: "int",account: "str" _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterUInt8.lower(role), _UniffiConverterString.lower(account)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4783,9 +4515,9 @@ def build_remove_validator_transaction(client: "LedgerClient",_from: "str",valid _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(_from), _UniffiConverterString.lower(validator_address)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4801,9 +4533,9 @@ def build_resolve_credential_definition_transaction(client: "LedgerClient",id: " _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_resolve_credential_definition_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(id)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4819,9 +4551,9 @@ def build_resolve_did_transaction(client: "LedgerClient",did: "str"): _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_resolve_did_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(did)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4837,9 +4569,9 @@ def build_resolve_schema_transaction(client: "LedgerClient",id: "str"): _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_resolve_schema_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(id)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4861,9 +4593,9 @@ def build_revoke_role_transaction(client: "LedgerClient",_from: "str",role: "int _UniffiConverterString.lower(_from), _UniffiConverterUInt8.lower(role), _UniffiConverterString.lower(account)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter @@ -4882,16 +4614,16 @@ def build_update_did_endorsing_data(client: "LedgerClient",did: "str",did_doc: " _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(did), _UniffiConverterString.lower(did_doc)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransactionEndorsingData.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_update_did_signed_transaction(client: "LedgerClient",_from: "str",did: "str",did_doc: "str",signature: "SignatureData"): +def build_update_did_transaction(client: "LedgerClient",_from: "str",did: "str",did_doc: "str"): _UniffiConverterTypeLedgerClient.check_lower(client) _UniffiConverterString.check_lower(_from) @@ -4900,47 +4632,41 @@ def build_update_did_signed_transaction(client: "LedgerClient",_from: "str",did: _UniffiConverterString.check_lower(did_doc) - _UniffiConverterTypeSignatureData.check_lower(signature) - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_update_did_signed_transaction( + _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_update_did_transaction( _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterString.lower(_from), _UniffiConverterString.lower(did), - _UniffiConverterString.lower(did_doc), - _UniffiConverterTypeSignatureData.lower(signature)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, + _UniffiConverterString.lower(did_doc)), + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, + _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function _UniffiConverterTypeTransaction.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) -def build_update_did_transaction(client: "LedgerClient",_from: "str",did: "str",did_doc: "str"): - _UniffiConverterTypeLedgerClient.check_lower(client) - - _UniffiConverterString.check_lower(_from) +def credential_definition_from_string(string: "str") -> "CredentialDefinition": + _UniffiConverterString.check_lower(string) - _UniffiConverterString.check_lower(did) + return _UniffiConverterTypeCredentialDefinition.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_credential_definition_from_string, + _UniffiConverterString.lower(string))) + + +def credential_definition_get_id(cred_def: "CredentialDefinition") -> "str": + _UniffiConverterTypeCredentialDefinition.check_lower(cred_def) - _UniffiConverterString.check_lower(did_doc) + return _UniffiConverterString.lift(_rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_credential_definition_get_id, + _UniffiConverterTypeCredentialDefinition.lower(cred_def))) + + +def credential_definition_to_string(data: "CredentialDefinition") -> "str": + _UniffiConverterTypeCredentialDefinition.check_lower(data) - return _uniffi_rust_call_async( - _UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_build_update_did_transaction( - _UniffiConverterTypeLedgerClient.lower(client), - _UniffiConverterString.lower(_from), - _UniffiConverterString.lower(did), - _UniffiConverterString.lower(did_doc)), - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_poll_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_pointer, - _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_pointer, - # lift function - _UniffiConverterTypeTransaction.lift, - # Error FFI converter - _UniffiConverterTypeVdrError, - ) + return _UniffiConverterString.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_credential_definition_to_string, + _UniffiConverterTypeCredentialDefinition.lower(data))) + def parse_did_attribute_changed_event_response(client: "LedgerClient",log: "EventLog") -> "DidAttributeChanged": _UniffiConverterTypeLedgerClient.check_lower(client) @@ -5032,12 +4758,12 @@ def parse_get_role_result(client: "LedgerClient",bytes: "bytes") -> "int": _UniffiConverterBytes.lower(bytes))) -def parse_get_validators_result(client: "LedgerClient",bytes: "bytes") -> "str": +def parse_get_validators_result(client: "LedgerClient",bytes: "bytes") -> "JsonValue": _UniffiConverterTypeLedgerClient.check_lower(client) _UniffiConverterBytes.check_lower(bytes) - return _UniffiConverterString.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_parse_get_validators_result, + return _UniffiConverterTypeJsonValue.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_parse_get_validators_result, _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterBytes.lower(bytes))) @@ -5052,32 +4778,32 @@ def parse_has_role_result(client: "LedgerClient",bytes: "bytes") -> "bool": _UniffiConverterBytes.lower(bytes))) -def parse_resolve_credential_definition_result(client: "LedgerClient",bytes: "bytes") -> "str": +def parse_resolve_credential_definition_result(client: "LedgerClient",bytes: "bytes") -> "JsonValue": _UniffiConverterTypeLedgerClient.check_lower(client) _UniffiConverterBytes.check_lower(bytes) - return _UniffiConverterString.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_parse_resolve_credential_definition_result, + return _UniffiConverterTypeJsonValue.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_parse_resolve_credential_definition_result, _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterBytes.lower(bytes))) -def parse_resolve_did_result(client: "LedgerClient",bytes: "bytes") -> "str": +def parse_resolve_did_result(client: "LedgerClient",bytes: "bytes") -> "JsonValue": _UniffiConverterTypeLedgerClient.check_lower(client) _UniffiConverterBytes.check_lower(bytes) - return _UniffiConverterString.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_parse_resolve_did_result, + return _UniffiConverterTypeJsonValue.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_parse_resolve_did_result, _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterBytes.lower(bytes))) -def parse_resolve_schema_result(client: "LedgerClient",bytes: "bytes") -> "str": +def parse_resolve_schema_result(client: "LedgerClient",bytes: "bytes") -> "JsonValue": _UniffiConverterTypeLedgerClient.check_lower(client) _UniffiConverterBytes.check_lower(bytes) - return _UniffiConverterString.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_parse_resolve_schema_result, + return _UniffiConverterTypeJsonValue.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_parse_resolve_schema_result, _UniffiConverterTypeLedgerClient.lower(client), _UniffiConverterBytes.lower(bytes))) @@ -5105,7 +4831,7 @@ def resolve_credential_definition(client: "LedgerClient",id: "str"): _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function - _UniffiConverterString.lift, + _UniffiConverterTypeCredentialDefinition.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) @@ -5126,7 +4852,7 @@ def resolve_did(client: "LedgerClient",did: "str",options: "typing.Optional[DidR _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function - _UniffiConverterString.lift, + _UniffiConverterTypeJsonValue.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) @@ -5144,11 +4870,130 @@ def resolve_schema(client: "LedgerClient",id: "str"): _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_complete_rust_buffer, _UniffiLib.ffi_indy_besu_vdr_uniffi_rust_future_free_rust_buffer, # lift function - _UniffiConverterString.lift, + _UniffiConverterTypeSchema.lift, # Error FFI converter _UniffiConverterTypeVdrError, ) +def schema_from_string(string: "str") -> "Schema": + _UniffiConverterString.check_lower(string) + + return _UniffiConverterTypeSchema.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_schema_from_string, + _UniffiConverterString.lower(string))) + + +def schema_get_id(schema: "Schema") -> "str": + _UniffiConverterTypeSchema.check_lower(schema) + + return _UniffiConverterString.lift(_rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_schema_get_id, + _UniffiConverterTypeSchema.lower(schema))) + + +def schema_to_string(data: "Schema") -> "str": + _UniffiConverterTypeSchema.check_lower(data) + + return _UniffiConverterString.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_schema_to_string, + _UniffiConverterTypeSchema.lower(data))) + + +def transaction_create(type: "TransactionType",to: "str",_from: "typing.Optional[str]",nonce: "typing.Optional[int]",chain_id: "int",data: "bytes",signature: "typing.Optional[SignatureData]",hash: "typing.Optional[bytes]") -> "Transaction": + _UniffiConverterTypeTransactionType.check_lower(type) + + _UniffiConverterString.check_lower(to) + + _UniffiConverterOptionalString.check_lower(_from) + + _UniffiConverterOptionalUInt64.check_lower(nonce) + + _UniffiConverterUInt64.check_lower(chain_id) + + _UniffiConverterBytes.check_lower(data) + + _UniffiConverterOptionalTypeSignatureData.check_lower(signature) + + _UniffiConverterOptionalBytes.check_lower(hash) + + return _UniffiConverterTypeTransaction.lift(_rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_create, + _UniffiConverterTypeTransactionType.lower(type), + _UniffiConverterString.lower(to), + _UniffiConverterOptionalString.lower(_from), + _UniffiConverterOptionalUInt64.lower(nonce), + _UniffiConverterUInt64.lower(chain_id), + _UniffiConverterBytes.lower(data), + _UniffiConverterOptionalTypeSignatureData.lower(signature), + _UniffiConverterOptionalBytes.lower(hash))) + + +def transaction_endorsing_data_create(to: "str",_from: "str",contract: "str",method: "str",endorsing_method: "str",params: "typing.List[JsonValue]",nonce: "typing.Optional[int]",signature: "typing.Optional[SignatureData]") -> "TransactionEndorsingData": + _UniffiConverterString.check_lower(to) + + _UniffiConverterString.check_lower(_from) + + _UniffiConverterString.check_lower(contract) + + _UniffiConverterString.check_lower(method) + + _UniffiConverterString.check_lower(endorsing_method) + + _UniffiConverterSequenceTypeJsonValue.check_lower(params) + + _UniffiConverterOptionalUInt64.check_lower(nonce) + + _UniffiConverterOptionalTypeSignatureData.check_lower(signature) + + return _UniffiConverterTypeTransactionEndorsingData.lift(_rust_call(_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_endorsing_data_create, + _UniffiConverterString.lower(to), + _UniffiConverterString.lower(_from), + _UniffiConverterString.lower(contract), + _UniffiConverterString.lower(method), + _UniffiConverterString.lower(endorsing_method), + _UniffiConverterSequenceTypeJsonValue.lower(params), + _UniffiConverterOptionalUInt64.lower(nonce), + _UniffiConverterOptionalTypeSignatureData.lower(signature))) + + +def transaction_endorsing_data_from_string(value: "str") -> "TransactionEndorsingData": + _UniffiConverterString.check_lower(value) + + return _UniffiConverterTypeTransactionEndorsingData.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_endorsing_data_from_string, + _UniffiConverterString.lower(value))) + + +def transaction_endorsing_data_get_signing_bytes(data: "TransactionEndorsingData") -> "bytes": + _UniffiConverterTypeTransactionEndorsingData.check_lower(data) + + return _UniffiConverterBytes.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_endorsing_data_get_signing_bytes, + _UniffiConverterTypeTransactionEndorsingData.lower(data))) + + +def transaction_endorsing_data_to_string(data: "TransactionEndorsingData") -> "str": + _UniffiConverterTypeTransactionEndorsingData.check_lower(data) + + return _UniffiConverterString.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_endorsing_data_to_string, + _UniffiConverterTypeTransactionEndorsingData.lower(data))) + + +def transaction_from_string(value: "str") -> "Transaction": + _UniffiConverterString.check_lower(value) + + return _UniffiConverterTypeTransaction.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_from_string, + _UniffiConverterString.lower(value))) + + +def transaction_get_signing_bytes(data: "Transaction") -> "bytes": + _UniffiConverterTypeTransaction.check_lower(data) + + return _UniffiConverterBytes.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_get_signing_bytes, + _UniffiConverterTypeTransaction.lower(data))) + + +def transaction_to_string(data: "Transaction") -> "str": + _UniffiConverterTypeTransaction.check_lower(data) + + return _UniffiConverterString.lift(_rust_call_with_error(_UniffiConverterTypeVdrError,_UniffiLib.uniffi_indy_besu_vdr_uniffi_fn_func_transaction_to_string, + _UniffiConverterTypeTransaction.lower(data))) + + __all__ = [ "InternalError", "DidEvents", @@ -5157,50 +5002,44 @@ def resolve_schema(client: "LedgerClient",id: "str"): "VdrError", "ContractConfig", "ContractSpec", + "CredentialDefinition", "DidAttributeChanged", "DidDelegateChanged", "DidOwnerChanged", "DidResolutionOptions", "EventLog", + "EventQuery", "PingStatus", "QuorumConfig", + "Schema", "SignatureData", - "TransactionSignature", + "Transaction", + "TransactionEndorsingData", "build_add_validator_transaction", "build_assign_role_transaction", "build_create_credential_definition_endorsing_data", - "build_create_credential_definition_signed_transaction", "build_create_credential_definition_transaction", "build_create_did_endorsing_data", "build_create_did_mapping_endorsing_data", - "build_create_did_mapping_signed_transaction", "build_create_did_mapping_transaction", - "build_create_did_signed_transaction", "build_create_did_transaction", "build_create_resource_mapping_endorsing_data", - "build_create_resource_mapping_signed_transaction", "build_create_resource_mapping_transaction", "build_create_schema_endorsing_data", - "build_create_schema_signed_transaction", "build_create_schema_transaction", "build_deactivate_did_endorsing_data", - "build_deactivate_did_signed_transaction", "build_deactivate_did_transaction", "build_did_add_delegate_endorsing_data", - "build_did_add_delegate_signed_transaction", "build_did_add_delegate_transaction", "build_did_change_owner_endorsing_data", - "build_did_change_owner_signed_transaction", "build_did_change_owner_transaction", "build_did_revoke_attribute_endorsing_data", - "build_did_revoke_attribute_signed_transaction", "build_did_revoke_attribute_transaction", "build_did_revoke_delegate_endorsing_data", - "build_did_revoke_delegate_signed_transaction", "build_did_revoke_delegate_transaction", "build_did_set_attribute_endorsing_data", - "build_did_set_attribute_signed_transaction", "build_did_set_attribute_transaction", + "build_endorsement_transaction", "build_get_did_changed_transaction", "build_get_did_events_query", "build_get_did_mapping_transaction", @@ -5216,8 +5055,10 @@ def resolve_schema(client: "LedgerClient",id: "str"): "build_resolve_schema_transaction", "build_revoke_role_transaction", "build_update_did_endorsing_data", - "build_update_did_signed_transaction", "build_update_did_transaction", + "credential_definition_from_string", + "credential_definition_get_id", + "credential_definition_to_string", "parse_did_attribute_changed_event_response", "parse_did_changed_result", "parse_did_delegate_changed_event_response", @@ -5236,9 +5077,17 @@ def resolve_schema(client: "LedgerClient",id: "str"): "resolve_credential_definition", "resolve_did", "resolve_schema", - "EventQuery", + "schema_from_string", + "schema_get_id", + "schema_to_string", + "transaction_create", + "transaction_endorsing_data_create", + "transaction_endorsing_data_from_string", + "transaction_endorsing_data_get_signing_bytes", + "transaction_endorsing_data_to_string", + "transaction_from_string", + "transaction_get_signing_bytes", + "transaction_to_string", "LedgerClient", - "Transaction", - "TransactionEndorsingData", ] diff --git a/vdr/wrappers/python/indy_besu_vdr/types.py b/vdr/wrappers/python/indy_besu_vdr/types.py new file mode 100644 index 00000000..7e33dc1c --- /dev/null +++ b/vdr/wrappers/python/indy_besu_vdr/types.py @@ -0,0 +1,413 @@ +import json +import typing + +import indy_besu_vdr +from indy_besu_vdr.indy_besu_vdr import * + + +class Transaction(indy_besu_vdr.indy_besu_vdr.Transaction): + def get_signing_bytes(self) -> bytes: + return transaction_get_signing_bytes(self) + + def set_signature(self, signature: SignatureData): + self.signature = signature + + def to_string(self) -> str: + return transaction_to_string(self) + + @classmethod + def from_string(cls, value: str) -> "Transaction": + return transaction_from_string(value) + + @classmethod + def init(cls, transaction: indy_besu_vdr.indy_besu_vdr.Transaction) -> "Transaction": + return Transaction( + transaction.type, + transaction._from, + transaction.to, + transaction.nonce, + transaction.chain_id, + transaction.data, + transaction.signature, + transaction.hash, + ) + + +class TransactionEndorsingData(indy_besu_vdr.indy_besu_vdr.TransactionEndorsingData): + def get_signing_bytes(self) -> bytes: + return transaction_endorsing_data_get_signing_bytes(self) + + def set_signature(self, signature: SignatureData): + self.signature = signature + + def to_string(self) -> str: + return transaction_endorsing_data_to_string(self) + + @classmethod + def from_string(cls, value: str) -> "TransactionEndorsingData": + return transaction_endorsing_data_from_string(value) + + @classmethod + def init(cls, transaction: indy_besu_vdr.indy_besu_vdr.TransactionEndorsingData) -> "TransactionEndorsingData": + return TransactionEndorsingData( + transaction.to, + transaction._from, + transaction.nonce, + transaction.contract, + transaction.method, + transaction.endorsing_method, + transaction.params, + transaction.signature, + ) + + +class DidIndyRegistry: + @staticmethod + async def build_create_did_transaction(client: LedgerClient, _from: str, did: str, did_doc: dict) -> "Transaction": + return Transaction.init(await build_create_did_transaction(client, _from, did, json.dumps(did_doc))) + + @staticmethod + async def build_create_did_endorsing_data(client: LedgerClient, did: str, + did_doc: dict) -> "TransactionEndorsingData": + return TransactionEndorsingData.init(await build_create_did_endorsing_data(client, did, json.dumps(did_doc))) + + @staticmethod + async def build_update_did_transaction(client: LedgerClient, _from: str, did: str, did_doc: dict) -> "Transaction": + return Transaction.init(await build_update_did_transaction(client, _from, did, json.dumps(did_doc))) + + @staticmethod + async def build_update_did_endorsing_data(client: LedgerClient, did: str, + did_doc: dict) -> "TransactionEndorsingData": + return TransactionEndorsingData.init(await build_update_did_endorsing_data(client, did, json.dumps(did_doc))) + + @staticmethod + async def build_deactivate_did_transaction(client: LedgerClient, _from: str, did: str) -> "Transaction": + return Transaction.init(await build_deactivate_did_transaction(client, _from, did)) + + @staticmethod + async def build_deactivate_did_endorsing_data(client: LedgerClient, did: str) -> "TransactionEndorsingData": + return TransactionEndorsingData.init(await build_deactivate_did_endorsing_data(client, did)) + + @staticmethod + async def build_resolve_did_transaction(client: LedgerClient, did: str) -> "Transaction": + return Transaction.init(await build_resolve_did_transaction(client, did)) + + @staticmethod + def parse_resolve_did_result(client: LedgerClient, data: bytes) -> str: + return parse_resolve_did_result(client, data) + + +class DidEthrRegistry: + @staticmethod + async def build_did_change_owner_transaction(client: LedgerClient, _from: str, did: str, + new_owner: str) -> "Transaction": + return Transaction.init(await build_did_change_owner_transaction(client, _from, did, new_owner)) + + @staticmethod + async def build_did_change_owner_endorsing_data(client: LedgerClient, did: str, + new_owner: str) -> "TransactionEndorsingData": + return TransactionEndorsingData.init(await build_did_change_owner_endorsing_data(client, did, new_owner)) + + @staticmethod + async def build_did_add_delegate_transaction(client: LedgerClient, _from: str, did: str, + delegate_type: str, delegate: str, validity: int) -> "Transaction": + return Transaction.init( + await build_did_add_delegate_transaction(client, _from, did, delegate_type, delegate, validity)) + + @staticmethod + async def build_did_add_delegate_endorsing_data(client: LedgerClient, did: str, + delegate_type: str, delegate: str, + validity: int) -> "TransactionEndorsingData": + return TransactionEndorsingData.init( + await build_did_add_delegate_endorsing_data(client, did, delegate_type, delegate, validity)) + + @staticmethod + async def build_did_revoke_delegate_transaction(client: LedgerClient, _from: str, did: str, + delegate_type: str, delegate: str) -> "Transaction": + return Transaction.init( + await build_did_revoke_delegate_transaction(client, _from, did, delegate_type, delegate)) + + @staticmethod + async def build_did_revoke_delegate_endorsing_data(client: LedgerClient, did: str, + delegate_type: str, delegate: str) -> "TransactionEndorsingData": + return TransactionEndorsingData.init( + await build_did_revoke_delegate_endorsing_data(client, did, delegate_type, delegate)) + + @staticmethod + async def build_did_set_attribute_transaction(client: LedgerClient, _from: str, did: str, + attribute: str, validity: int) -> "Transaction": + return Transaction.init( + await build_did_set_attribute_transaction(client, _from, did, attribute, validity)) + + @staticmethod + async def build_did_set_attribute_endorsing_data(client: LedgerClient, did: str, attribute: dict, + validity: int) -> "TransactionEndorsingData": + return TransactionEndorsingData.init( + await build_did_set_attribute_endorsing_data(client, did, json.dumps(attribute), validity)) + + @staticmethod + async def build_did_revoke_attribute_transaction(client: LedgerClient, _from: str, did: str, + attribute: dict) -> "Transaction": + return Transaction.init( + await build_did_revoke_attribute_transaction(client, _from, did, json.dumps(attribute))) + + @staticmethod + async def build_did_revoke_attribute_endorsing_data(client: LedgerClient, did: str, + attribute: str) -> "TransactionEndorsingData": + return TransactionEndorsingData.init( + await build_did_revoke_attribute_endorsing_data(client, did, attribute)) + + @staticmethod + async def build_get_did_owner_transaction(client: LedgerClient, did: str) -> "Transaction": + return Transaction.init(await build_get_did_owner_transaction(client, did)) + + @staticmethod + async def build_get_did_changed_transaction(client: LedgerClient, did: str) -> "Transaction": + return Transaction.init(await build_get_did_changed_transaction(client, did)) + + @staticmethod + async def build_get_identity_nonce_transaction(client: LedgerClient, did: str) -> "Transaction": + return Transaction.init(await build_get_identity_nonce_transaction(client, did)) + + @staticmethod + async def build_get_did_events_query(client: LedgerClient, did: str, from_block: typing.Optional[int], + to_block: typing.Optional[int]) -> "EventQuery": + return await build_get_did_events_query(client, did, from_block, to_block) + + @staticmethod + def parse_did_changed_result(client: LedgerClient, data: bytes) -> int: + return parse_did_changed_result(client, data) + + @staticmethod + def parse_did_nonce_result(client: LedgerClient, data: bytes) -> int: + return parse_did_nonce_result(client, data) + + @staticmethod + def parse_did_owner_result(client: LedgerClient, data: bytes) -> str: + return parse_did_owner_result(client, data) + + @staticmethod + def parse_did_attribute_changed_event_response(client: LedgerClient, data: EventLog) -> DidAttributeChanged: + return parse_did_attribute_changed_event_response(client, data) + + @staticmethod + def parse_did_delegate_changed_event_response(client: LedgerClient, data: EventLog) -> DidDelegateChanged: + return parse_did_delegate_changed_event_response(client, data) + + @staticmethod + def parse_did_owner_changed_event_response(client: LedgerClient, data: EventLog) -> DidOwnerChanged: + return parse_did_owner_changed_event_response(client, data) + + @staticmethod + def parse_did_event_response(client: LedgerClient, data: EventLog) -> DidEvents: + return parse_did_event_response(client, data) + + +class DidResolver: + @staticmethod + async def resolve_did(client: LedgerClient, did: str, options: typing.Optional[DidResolutionOptions]) -> str: + return await resolve_did(client, did, options) + + +class Schema(indy_besu_vdr.indy_besu_vdr.Schema): + def __init__(self, issuer_id: "str", name: "str", version: "str", attr_names: "typing.List[str]"): + super().__init__(issuer_id, name, version, attr_names) + + @property + def id(self) -> str: + return schema_get_id(self) + + @classmethod + def init(cls, schema: indy_besu_vdr.indy_besu_vdr.Schema) -> "Schema": + return Schema( + schema.issuer_id, + schema.name, + schema.version, + schema.attr_names, + ) + + def to_string(self) -> str: + return schema_to_string(self) + + @classmethod + def from_string(cls, value: str) -> "Schema": + return Schema.init(schema_from_string(value)) + + +class SchemaRegistry: + @staticmethod + async def build_create_schema_transaction(client: LedgerClient, _from: str, schema: dict) -> "Transaction": + return Transaction.init(await build_create_schema_transaction(client, _from, json.dumps(schema))) + + @staticmethod + async def build_create_schema_endorsing_data(client: LedgerClient, schema: Schema) -> "TransactionEndorsingData": + return TransactionEndorsingData.init(await build_create_schema_endorsing_data(client, schema)) + + @staticmethod + async def build_resolve_schema_transaction(client: LedgerClient, id: str) -> "Transaction": + return Transaction.init(await build_resolve_schema_transaction(client, id)) + + @staticmethod + def parse_resolve_schema_result(client: LedgerClient, data: bytes) -> str: + return parse_resolve_schema_result(client, data) + + @staticmethod + async def resolve_schema(client: LedgerClient, id: str) -> Schema: + return Schema.init(await resolve_schema(client, id)) + + +class CredentialDefinition(indy_besu_vdr.indy_besu_vdr.CredentialDefinition): + def __init__(self, issuer_id: "str", schema_id: "str", cred_def_type: "str", tag: "str", value: "JsonValue"): + super().__init__(issuer_id, schema_id, cred_def_type, tag, value) + + @property + def id(self) -> str: + return credential_definition_get_id(self) + + @classmethod + def init(cls, cred_def: indy_besu_vdr.indy_besu_vdr.CredentialDefinition) -> "CredentialDefinition": + return CredentialDefinition( + cred_def.issuer_id, + cred_def.schema_id, + cred_def.cred_def_type, + cred_def.tag, + cred_def.value, + ) + + def to_string(self) -> str: + return credential_definition_to_string(self) + + @classmethod + def from_string(cls, value: str) -> "CredentialDefinition": + return CredentialDefinition.init(credential_definition_from_string(value)) + + +class CredentialDefinitionRegistry: + @staticmethod + async def build_create_credential_definition_transaction(client: LedgerClient, _from: str, + credential_definition: dict) -> "Transaction": + return Transaction.init( + await build_create_credential_definition_transaction(client, _from, json.dumps(credential_definition))) + + @staticmethod + async def build_create_credential_definition_endorsing_data(client: LedgerClient, + credential_definition: dict) -> "TransactionEndorsingData": + return TransactionEndorsingData.init( + await build_create_credential_definition_endorsing_data(client, json.dumps(credential_definition))) + + @staticmethod + async def build_resolve_credential_definition_transaction(client: LedgerClient, id: str) -> "Transaction": + return Transaction(await build_resolve_credential_definition_transaction(client, id)) + + @staticmethod + def parse_resolve_credential_definition_result(client: LedgerClient, data: bytes) -> str: + return parse_resolve_credential_definition_result(client, data) + + @staticmethod + async def resolve_credential_definition(client: LedgerClient, id: str) -> str: + return await resolve_credential_definition(client, id) + + +class LegacyMapping: + @staticmethod + async def build_create_did_mapping_transaction(client: LedgerClient, _from: str, did: str, legacy_identifier: str, + legacy_verkey: str, ed25519_signature: bytes) -> "Transaction": + return Transaction.init( + await build_create_did_mapping_transaction(client, _from, did, legacy_identifier, legacy_verkey, + ed25519_signature)) + + @staticmethod + async def build_create_did_mapping_endorsing_data(client: LedgerClient, did: str, legacy_identifier: str, + legacy_verkey: str, + ed25519_signature: bytes) -> "TransactionEndorsingData": + return TransactionEndorsingData.init( + await build_create_did_mapping_endorsing_data(client, did, legacy_identifier, legacy_verkey, + ed25519_signature)) + + @staticmethod + async def build_get_did_mapping_transaction(client: LedgerClient, legacy_identifier: str) -> "Transaction": + return Transaction.init(await build_get_did_mapping_transaction(client, legacy_identifier)) + + @staticmethod + def parse_did_mapping_result(client: LedgerClient, data: bytes) -> str: + return parse_did_mapping_result(client, data) + + @staticmethod + async def build_create_resource_mapping_transaction(client: LedgerClient, _from: str, did: str, + legacy_issuer_identifier: str, legacy_identifier: str, + new_identifier: str) -> "Transaction": + return Transaction.init( + await build_create_resource_mapping_transaction(client, _from, did, legacy_issuer_identifier, + legacy_identifier, + new_identifier)) + + @staticmethod + async def build_create_resource_mapping_endorsing_data(client: LedgerClient, did: str, + legacy_issuer_identifier: str, legacy_identifier: str, + new_identifier: str) -> "TransactionEndorsingData": + return TransactionEndorsingData.init( + await build_create_resource_mapping_endorsing_data(client, did, legacy_issuer_identifier, legacy_identifier, + new_identifier)) + + @staticmethod + async def build_get_resource_mapping_transaction(client: LedgerClient, legacy_identifier: str) -> "Transaction": + return Transaction.init(await build_get_resource_mapping_transaction(client, legacy_identifier)) + + @staticmethod + def parse_resource_mapping_result(client: LedgerClient, data: bytes) -> str: + return parse_resource_mapping_result(client, data) + + +class Endorsement: + @staticmethod + async def build_endorsement_transaction(client: LedgerClient, _from: str, + endorsement_data: "TransactionEndorsingData") -> "Transaction": + return Transaction.init(await build_endorsement_transaction(client, _from, endorsement_data)) + + +class RoleControl: + @staticmethod + async def build_assign_role_transaction(client: LedgerClient, _from: str, + role: int, account: str) -> "Transaction": + return Transaction.init(await build_assign_role_transaction(client, _from, role, account)) + + @staticmethod + async def build_revoke_role_transaction(client: LedgerClient, _from: str, + role: int, account: str) -> "Transaction": + return Transaction.init(await build_revoke_role_transaction(client, _from, role, account)) + + @staticmethod + async def build_has_role_transaction(client: LedgerClient, role: int, account: str) -> "Transaction": + return Transaction.init(await build_has_role_transaction(client, role, account)) + + @staticmethod + async def build_get_role_transaction(client: LedgerClient, account: str) -> "Transaction": + return Transaction.init(await build_get_role_transaction(client, account)) + + @staticmethod + def parse_has_role_result(client: LedgerClient, data: bytes) -> bool: + return parse_has_role_result(client, data) + + @staticmethod + def parse_get_role_result(client: LedgerClient, data: bytes) -> int: + return parse_get_role_result(client, data) + + +class ValidatorControl: + @staticmethod + async def build_add_validator_transaction(client: LedgerClient, _from: str, + validator_address: str) -> "Transaction": + return Transaction.init(await build_add_validator_transaction(client, _from, validator_address)) + + @staticmethod + async def build_remove_validator_transaction(client: LedgerClient, _from: str, + validator_address: str) -> "Transaction": + return Transaction.init(await build_remove_validator_transaction(client, _from, validator_address)) + + @staticmethod + async def build_get_validators_transaction(client: LedgerClient) -> "Transaction": + return Transaction.init(await build_get_validators_transaction(client)) + + @staticmethod + def parse_get_validators_result(client: LedgerClient) -> str: + return parse_get_validators_result(client)