Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Credentials #2829

Merged
merged 77 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
c929e51
create credentials obj, modify depositpreauth
achowdhry-ripple Nov 14, 2024
55f92d2
structrure of transaction models
achowdhry-ripple Nov 14, 2024
63a4228
initial validation methods and modify transactions affected by deposi…
achowdhry-ripple Nov 14, 2024
fd6b92a
cleanup and add new transactions to list
achowdhry-ripple Nov 14, 2024
398bfd4
binarycodec and add amendments to config
achowdhry-ripple Nov 15, 2024
b1bdf27
methods account for credentials
achowdhry-ripple Nov 15, 2024
4c3080b
binary codec update
achowdhry-ripple Nov 15, 2024
0214322
add amendments to config
achowdhry-ripple Nov 15, 2024
eb7acd7
error validation for credentials actions
achowdhry-ripple Nov 15, 2024
e79dd3c
core logic of error validation completed
achowdhry-ripple Nov 15, 2024
b50066b
type checking in error validation
achowdhry-ripple Nov 18, 2024
4eb3142
init test files and field type validations
achowdhry-ripple Nov 20, 2024
fdd23ac
basic tests for crud transactions
achowdhry-ripple Nov 21, 2024
fe916f8
cred delete tests
achowdhry-ripple Nov 21, 2024
85a5d98
cred accept unit tests
achowdhry-ripple Nov 25, 2024
3d88dcc
cred create and accept unit tests
achowdhry-ripple Nov 25, 2024
c37d0e1
cred delete unit tests
achowdhry-ripple Nov 25, 2024
ac5a08a
depositPreauth unit tests
achowdhry-ripple Nov 25, 2024
86e3877
generic checks for payment, paymentchannelclaim, escrowfinish credent…
achowdhry-ripple Nov 25, 2024
5c71393
ledger entry update
achowdhry-ripple Nov 25, 2024
0ce1521
lint errors
achowdhry-ripple Nov 25, 2024
9ff421b
cleanup and use helper methods
achowdhry-ripple Nov 25, 2024
6e3cf3d
fix lint bug
achowdhry-ripple Nov 25, 2024
d328725
init integration tests for new transactions
achowdhry-ripple Nov 26, 2024
b472808
fix build error, integration test docker update
achowdhry-ripple Nov 26, 2024
350b3fb
unit test fixes -- all pass now
achowdhry-ripple Nov 26, 2024
1fe6707
integration test layout complete
achowdhry-ripple Nov 27, 2024
0c1f6b3
integration command
achowdhry-ripple Dec 2, 2024
5f71338
integration tests run
achowdhry-ripple Dec 2, 2024
f7113a0
cicd command edit
achowdhry-ripple Dec 2, 2024
e5e772a
lint and cleanup
achowdhry-ripple Dec 2, 2024
f323f95
modified history markdown
achowdhry-ripple Dec 2, 2024
6197506
deposit preauth integration update
achowdhry-ripple Dec 2, 2024
7c665b9
update docs with new docker command
achowdhry-ripple Dec 2, 2024
351b1c2
fix validation for string id credential arrays
achowdhry-ripple Dec 3, 2024
18a04b3
exports
achowdhry-ripple Dec 5, 2024
41e125e
add flag
achowdhry-ripple Dec 5, 2024
f82e974
lint
achowdhry-ripple Dec 6, 2024
231173d
fix typo in contributing doc
achowdhry-ripple Dec 6, 2024
414e45a
docstring typos
achowdhry-ripple Dec 6, 2024
e6941fa
readable string
achowdhry-ripple Dec 6, 2024
425bf7a
fix test'
achowdhry-ripple Dec 6, 2024
38e81f7
review comment fixes
achowdhry-ripple Dec 18, 2024
c353b4e
txn duplicate fix
achowdhry-ripple Dec 18, 2024
44b9449
Apply suggestions from code review
achowdhry-ripple Dec 18, 2024
0388a52
Apply suggestions from code review
achowdhry-ripple Dec 18, 2024
e67404e
Apply suggestions from code review
achowdhry-ripple Dec 18, 2024
a13e43c
typo in auto suggest
achowdhry-ripple Dec 18, 2024
d1aa99d
rebase
achowdhry-ripple Dec 18, 2024
99cbf20
readd definitions after rebase
achowdhry-ripple Dec 18, 2024
68e14a5
cleanup list val
achowdhry-ripple Dec 18, 2024
1dec273
unit tests fixed and running
achowdhry-ripple Dec 18, 2024
f30f9f5
lint
achowdhry-ripple Dec 18, 2024
250a67c
refactor authcred check to work
achowdhry-ripple Dec 19, 2024
0dc3594
Update packages/xrpl/src/models/transactions/payment.ts
achowdhry-ripple Dec 19, 2024
0b2cbb3
typo
achowdhry-ripple Dec 19, 2024
e75783c
Update .ci-config/rippled.cfg
achowdhry-ripple Dec 19, 2024
77a1915
update rippled version
achowdhry-ripple Dec 19, 2024
e9ff56b
optional field nits
achowdhry-ripple Dec 19, 2024
d54d291
add to response depositauthorize
achowdhry-ripple Dec 19, 2024
72300d8
Update packages/xrpl/src/models/transactions/CredentialCreate.ts
achowdhry-ripple Dec 19, 2024
2a96c26
Update packages/xrpl/src/models/transactions/CredentialDelete.ts
achowdhry-ripple Dec 19, 2024
1116f2c
Update packages/xrpl/src/models/transactions/accountDelete.ts
achowdhry-ripple Dec 19, 2024
ae0e2e1
Apply suggestions from code review
achowdhry-ripple Dec 19, 2024
26c25df
cleanups
achowdhry-ripple Dec 19, 2024
70cbb5a
unit test fix
achowdhry-ripple Dec 19, 2024
2b3bf81
more escrowfinish tests
achowdhry-ripple Dec 19, 2024
0ea8a45
clearer error message
achowdhry-ripple Dec 19, 2024
1c6431a
re add statement
achowdhry-ripple Dec 19, 2024
be41ae9
undo autodeleted mandates
achowdhry-ripple Dec 19, 2024
9a5d813
remove extraneous integration tests for now
achowdhry-ripple Dec 20, 2024
4bcf387
lint
achowdhry-ripple Dec 20, 2024
1812f61
Update .ci-config/rippled.cfg
achowdhry-ripple Dec 20, 2024
730b57e
Update packages/xrpl/src/models/transactions/common.ts
achowdhry-ripple Dec 20, 2024
f6ab8af
added tests
achowdhry-ripple Dec 20, 2024
4b6b74b
Merge branch 'main' into verifiable-credentials
achowdhry-ripple Dec 20, 2024
bfb9d06
typo
achowdhry-ripple Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci-config/rippled.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ PriceOracle
fixEmptyDID
fixXChainRewardRounding
fixPreviousTxnID
# 2.3.0-rc1 Amendments
fixAMMv1_1
achowdhry-ripple marked this conversation as resolved.
Show resolved Hide resolved
# 2.3.0 Amendments
Credentials
achowdhry-ripple marked this conversation as resolved.
Show resolved Hide resolved
NFTokenMintOffer
MPTokensV1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:

- name: Run docker in background
run: |
docker run --detach --rm -p 6006:6006 --volume "${{ github.workspace }}/.ci-config/":"/etc/opt/ripple/" --name rippled-service --health-cmd="rippled server_nfo || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s --env GITHUB_ACTIONS=true --env CI=true --entrypoint bash ${{ env.RIPPLED_DOCKER_IMAGE }} -c "rippled -a"
docker run --detach --rm -p 6006:6006 --volume "${{ github.workspace }}/.ci-config/":"/etc/opt/ripple/" --name rippled-service --health-cmd="rippled server_info || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s --env GITHUB_ACTIONS=true --env CI=true --entrypoint bash ${{ env.RIPPLED_DOCKER_IMAGE }} -c "rippled -a"

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
Expand Down Expand Up @@ -162,7 +162,7 @@ jobs:

- name: Run docker in background
run: |
docker run --detach --rm -p 6006:6006 --volume "${{ github.workspace }}/.ci-config/":"/etc/opt/ripple/" --name rippled-service --health-cmd="rippled server_nfo || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s --env GITHUB_ACTIONS=true --env CI=true --entrypoint bash ${{ env.RIPPLED_DOCKER_IMAGE }} -c "rippled -a"
docker run --detach --rm -p 6006:6006 --volume "${{ github.workspace }}/.ci-config/":"/etc/opt/ripple/" --name rippled-service --health-cmd="rippled server_info || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s --env GITHUB_ACTIONS=true --env CI=true --entrypoint bash ${{ env.RIPPLED_DOCKER_IMAGE }} -c "rippled -a"

- name: Setup npm version 10
run: |
Expand Down
14 changes: 8 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,20 @@ From the top-level xrpl.js folder (one level above `packages`), run the followin
```bash
npm install
# sets up the rippled standalone Docker container - you can skip this step if you already have it set up
docker run -p 6006:6006 --interactive -t --volume $PWD/.ci-config:/opt/ripple/etc/ --platform linux/amd64 rippleci/rippled:2.0.0-b4 /opt/ripple/bin/rippled -a --conf /opt/ripple/etc/rippled.cfg
docker run -p 6006:6006 --rm -it --name rippled_standalone --volume $PWD/.ci-config:/etc/opt/ripple/ --entrypoint bash rippleci/rippled:2.3.0-rc1 -c 'rippled -a'
npm run build
npm run test:integration
```

Breaking down the command:
* `docker run -p 6006:6006` starts a Docker container with an open port for admin WebSocket requests.
* `--interactive` allows you to interact with the container.
* `-t` starts a terminal in the container for you to send commands to.
* `--volume $PWD/.ci-config:/config/` identifies the `rippled.cfg` and `validators.txt` to import. It must be an absolute path, so we use `$PWD` instead of `./`.
`--rm` tells docker to close the container after processes are done running.
* `-it` allows you to interact with the container.
`--name rippled_standalone` is an instance name for clarity
* `--volume $PWD/.ci-config:/etc/opt/ripple/` identifies the `rippled.cfg` and `validators.txt` to import. It must be an absolute path, so we use `$PWD` instead of `./`.
* `rippleci/rippled` is an image that is regularly updated with the latest `rippled` releases
* `/opt/ripple/bin/rippled -a --conf /opt/ripple/etc/rippled.cfg` starts `rippled` in standalone mode
* `--entrypoint bash rippleci/rippled:2.3.0-rc1` manually overrides the entrypoint (for versions of rippled >= 2.3.0)
* `-c 'rippled -a'` provides the bash command to start `rippled` in standalone mode from the manual entrypoint

### Browser Tests

Expand All @@ -90,7 +92,7 @@ This should be run from the `xrpl.js` top level folder (one above the `packages`
```bash
npm run build
# sets up the rippled standalone Docker container - you can skip this step if you already have it set up
docker run -p 6006:6006 --interactive -t --volume $PWD/.ci-config:/opt/ripple/etc/ --platform linux/amd64 rippleci/rippled:2.2.0-b3 /opt/ripple/bin/rippled -a --conf /opt/ripple/etc/rippled.cfg
docker run -p 6006:6006 --rm -it --name rippled_standalone --volume $PWD/.ci-config:/etc/opt/ripple/ --entrypoint bash rippleci/rippled:2.3.0-rc1 -c 'rippled -a'
npm run test:browser
```

Expand Down
85 changes: 85 additions & 0 deletions packages/ripple-binary-codec/src/enums/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,26 @@
"type": "UInt64"
}
],
[
"IssuerNode",
{
"nth": 27,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt64"
}
],
[
"SubjectNode",
{
"nth": 28,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt64"
}
],
[
"EmailHash",
{
Expand Down Expand Up @@ -1810,6 +1830,16 @@
"type": "Blob"
}
],
[
"CredentialType",
{
"nth": 31,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "Blob"
}
],
[
"Account",
{
Expand Down Expand Up @@ -1980,6 +2010,16 @@
"type": "AccountID"
}
],
[
"Subject",
{
"nth": 24,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "AccountID"
}
],
[
"TransactionMetaData",
{
Expand Down Expand Up @@ -2270,6 +2310,16 @@
"type": "STObject"
}
],
[
"Credential",
{
"nth": 33,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STObject"
}
],
[
"Signers",
{
Expand Down Expand Up @@ -2460,6 +2510,26 @@
"type": "STArray"
}
],
[
"AuthorizeCredentials",
{
"nth": 26,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STArray"
}
],
[
"UnauthorizeCredentials",
{
"nth": 27,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STArray"
}
],
[
"CloseResolution",
{
Expand Down Expand Up @@ -2640,6 +2710,16 @@
"type": "Vector256"
}
],
[
"CredentialIDs",
{
"nth": 5,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "Vector256"
}
],
[
"MPTokenIssuanceID",
{
Expand Down Expand Up @@ -2781,6 +2861,7 @@
"NegativeUNL": 78,
"Offer": 111,
"Oracle": 128,
"Credential": 129,
"PayChannel": 120,
"RippleState": 114,
"SignerList": 83,
Expand All @@ -2797,6 +2878,7 @@
"tecAMM_NOT_EMPTY": 167,
"tecARRAY_EMPTY": 190,
"tecARRAY_TOO_LARGE": 191,
"tecBAD_CREDENTIALS": 193,
"tecCANT_ACCEPT_OWN_NFTOKEN_OFFER": 158,
"tecCLAIM": 100,
"tecCRYPTOCONDITION_ERROR": 146,
Expand Down Expand Up @@ -2982,6 +3064,9 @@
"CheckCash": 17,
"CheckCreate": 16,
"Clawback": 30,
"CredentialCreate": 58,
"CredentialAccept": 59,
"CredentialDelete": 60,
"DIDDelete": 50,
"DIDSet": 49,
"DepositPreauth": 19,
Expand Down
3 changes: 2 additions & 1 deletion packages/xrpl/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr
## Unreleased Changes

### Added
* parseTransactionFlags as a utility function in the xrpl package to streamline transactions flags-to-map conversion
* Added new MPT transaction definitions (XLS-33)
* New `MPTAmount` type support for `Payment` and `Clawback` transactions
* `parseTransactionFlags` as a utility function in the xrpl package to streamline transactions flags-to-map conversion
* Support for XLS-70d (Credentials)

### Fixed
* `TransactionStream` model supports APIv2
Expand Down
10 changes: 10 additions & 0 deletions packages/xrpl/src/models/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ export interface AuthAccount {
}
}

export interface AuthorizeCredential {
Credential: {
/** The issuer of the credential. */
Issuer: string

/** A hex-encoded value to identify the type of credential from the issuer. */
CredentialType: string
}
}

export interface XChainBridge {
LockingChainDoor: string
LockingChainIssue: Currency
Expand Down
47 changes: 47 additions & 0 deletions packages/xrpl/src/models/ledger/Credential.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { GlobalFlags } from '../transactions/common'

import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
mvadari marked this conversation as resolved.
Show resolved Hide resolved

export interface CredentialFlags extends GlobalFlags {
lsfAccepted?: boolean
}

/**
*
* A Credential object describes a credential, similar to a passport, which is an issuable identity verifier
* that can be used as a prerequisite for other transactions
*
* @category Ledger Entries
*/
export default interface Credential extends BaseLedgerEntry, HasPreviousTxnID {
LedgerEntryType: 'Credential'
/**
* A bit-map of boolean flags
*/
Flags: number | CredentialFlags

/** The account that the credential is for. */
Subject: string

/** The issuer of the credential. */
Issuer: string

/** A hex-encoded value to identify the type of credential from the issuer. */
CredentialType: string

/** A hint indicating which page of the subject's owner directory links to this object,
* in case the directory consists of multiple pages.
*/
SubjectNode: string

/** A hint indicating which page of the issuer's owner directory links to this object,
* in case the directory consists of multiple pages.
*/
IssuerNode: string

/** Credential expiration. */
Expiration?: number

/** Additional data about the credential (such as a link to the VC document). */
URI?: string
}
8 changes: 6 additions & 2 deletions packages/xrpl/src/models/ledger/DepositPreauth.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { AuthorizeCredential } from '../common'

import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'

/**
Expand All @@ -12,8 +14,6 @@ export default interface DepositPreauth
LedgerEntryType: 'DepositPreauth'
/** The account that granted the preauthorization. */
Account: string
/** The account that received the preauthorization. */
Authorize: string
/**
* A bit-map of boolean flags. No flags are defined for DepositPreauth
* objects, so this value is always 0.
Expand All @@ -24,4 +24,8 @@ export default interface DepositPreauth
* object, in case the directory consists of multiple pages.
*/
OwnerNode: string
/** The account that received the preauthorization. */
Authorize?: string
/** The credential(s) that received the preauthorization. */
AuthorizeCredentials?: AuthorizeCredential[]
}
3 changes: 3 additions & 0 deletions packages/xrpl/src/models/ledger/LedgerEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Amendments from './Amendments'
import AMM from './AMM'
import Bridge from './Bridge'
import Check from './Check'
import Credential from './Credential'
import DepositPreauth from './DepositPreauth'
import DirectoryNode from './DirectoryNode'
import Escrow from './Escrow'
Expand All @@ -24,6 +25,7 @@ type LedgerEntry =
| AMM
| Bridge
| Check
| Credential
| DepositPreauth
| DirectoryNode
| Escrow
Expand All @@ -45,6 +47,7 @@ type LedgerEntryFilter =
| 'amm'
| 'bridge'
| 'check'
| 'credential'
| 'deposit_preauth'
| 'did'
| 'directory'
Expand Down
2 changes: 2 additions & 0 deletions packages/xrpl/src/models/ledger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Amendments, { Majority, AMENDMENTS_ID } from './Amendments'
import AMM, { VoteSlot } from './AMM'
import Bridge from './Bridge'
import Check from './Check'
import Credential from './Credential'
import DepositPreauth from './DepositPreauth'
import DID from './DID'
import DirectoryNode from './DirectoryNode'
Expand Down Expand Up @@ -41,6 +42,7 @@ export {
AMM,
Bridge,
Check,
Credential,
DepositPreauth,
DirectoryNode,
DID,
Expand Down
10 changes: 10 additions & 0 deletions packages/xrpl/src/models/methods/depositAuthorized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export interface DepositAuthorizedRequest
source_account: string
/** The recipient of a possible payment. */
destination_account: string
/**
* The object IDs of Credential objects. If this field is included, then the
* credential will be taken into account when analyzing whether the sender can send
* funds to the destination.
*/
credentials?: string[]
}

/**
achowdhry-ripple marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -52,5 +58,9 @@ export interface DepositAuthorizedResponse extends BaseResponse {
source_account: string
/** If true, the information comes from a validated ledger version. */
validated?: boolean
/** The object IDs of `Credential` objects. If this field is included,
* then the credential will be taken into account when analyzing whether
* the sender can send funds to the destination. */
credentials?: string[]
}
}
17 changes: 17 additions & 0 deletions packages/xrpl/src/models/methods/ledgerEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
/** The object ID of a Check object to retrieve. */
check?: string

/* Specify the Credential to retrieve. If a string, must be the ledger entry ID of
* the entry, as hexadecimal. If an object, requires subject, issuer, and
* credential_type sub-fields.
*/
credential?:
| {
/** The account that is the subject of the credential. */
subject: string

/** The account that issued the credential. */
issuer: string

/** The type of the credential, as issued. */
credentialType: string
}
| string
mvadari marked this conversation as resolved.
Show resolved Hide resolved

/**
* Specify a DepositPreauth object to retrieve. If a string, must be the
* object ID of the DepositPreauth object, as hexadecimal. If an object,
Expand Down
Loading
Loading