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

[Draft] Implement phase 3 of offramp prototype #22

Merged
merged 59 commits into from
May 2, 2024

Conversation

ebma
Copy link
Member

@ebma ebma commented Apr 25, 2024

Follow-up to #18. Only merge once #18 is merged.

Closes #20.
Addresses comments from previous PR.

Server signature process

The service exposes two endpoints, /v1/stellar/create and /v1/stellar/payment.
The first will provide the signature for the creation and trust opening operation of the specified ephemeral account's address.
The second will provide two signatures: One for a payment transaction of a specified amount and destination, and another one for a trust closing and merge operation.

Sequence passing

For the first signing operation, the sequence number of the funding account will be provided from the service to the UI, which will load the account with this sequence number and public key to create the corresponding mirror transaction.

For the second call, the UI provides the sequence number to the service, which it will use to create the transactions and send the signatures.

Potential bugs

Several processes querying the same signing service could produce a situation in which the sequence number specified by the signing service is not valid if more than two signatures are created in parallel, at least for one of them.

This can be partially avoided by keeping a global sequence state on the service, but still the problem exists that the corresponding transactions must be executed by the UI in the order by which the service signed them, which is not certain since the UI may execute at different speeds due to network issues.

@ebma ebma changed the base branch from main to offramp-prototype-staging April 25, 2024 10:14
Copy link

yarn.lock changes

Summary

Status Count
ADDED 289
UPDATED 64
DOWNGRADED 1
REMOVED 6
Click to toggle table visibility
Name Status Previous Current
@chainsafe/metamask-polkadot-adapter ADDED - 0.6.0
@chainsafe/metamask-polkadot-types ADDED - 0.7.0
@esbuild-plugins/node-globals-polyfill REMOVED 0.1.1 -
@esbuild-plugins/node-modules-polyfill REMOVED 0.1.4 -
@jspm/core ADDED - 2.0.1
@lit-labs/ssr-dom-shim ADDED - 1.2.0
@lit/reactive-element ADDED - 1.6.3
@motionone/animation ADDED - 10.17.0
@motionone/dom ADDED - 10.17.0
@motionone/easing ADDED - 10.17.0
@motionone/generators ADDED - 10.17.0
@motionone/svelte ADDED - 10.16.4
@motionone/types ADDED - 10.17.0
@motionone/utils ADDED - 10.17.0
@motionone/vue ADDED - 10.16.4
@noble/curves UPDATED 1.0.0 1.4.0
@noble/hashes UPDATED 1.3.0 1.4.0
@parcel/watcher ADDED - 2.4.1
@parcel/watcher-android-arm64 ADDED - 2.4.1
@parcel/watcher-darwin-arm64 ADDED - 2.4.1
@parcel/watcher-darwin-x64 ADDED - 2.4.1
@parcel/watcher-freebsd-x64 ADDED - 2.4.1
@parcel/watcher-linux-arm-glibc ADDED - 2.4.1
@parcel/watcher-linux-arm64-glibc ADDED - 2.4.1
@parcel/watcher-linux-arm64-musl ADDED - 2.4.1
@parcel/watcher-linux-x64-glibc ADDED - 2.4.1
@parcel/watcher-linux-x64-musl ADDED - 2.4.1
@parcel/watcher-wasm ADDED - 2.4.1
@parcel/watcher-win32-arm64 ADDED - 2.4.1
@parcel/watcher-win32-ia32 ADDED - 2.4.1
@parcel/watcher-win32-x64 ADDED - 2.4.1
@polkadot-api/client ADDED - 0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0
@polkadot-api/json-rpc-provider ADDED - 0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0
@polkadot-api/json-rpc-provider-proxy ADDED - 0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0
@polkadot-api/metadata-builders ADDED - 0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0
@polkadot-api/substrate-bindings ADDED - 0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0
@polkadot-api/substrate-client ADDED - 0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0
@polkadot-api/utils ADDED - 0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0
@polkadot/api UPDATED 10.6.1 10.13.1
@polkadot/api-augment UPDATED 10.6.1 10.13.1
@polkadot/api-base UPDATED 10.6.1 10.13.1
@polkadot/api-derive UPDATED 10.6.1 10.13.1
@polkadot/extension-dapp ADDED - 0.47.1
@polkadot/extension-inject ADDED - 0.47.1
@polkadot/keyring UPDATED 12.1.2 12.6.2
@polkadot/networks UPDATED 12.1.2 12.6.2
@polkadot/rpc-augment UPDATED 10.6.1 10.13.1
@polkadot/rpc-core UPDATED 10.6.1 10.13.1
@polkadot/rpc-provider UPDATED 10.6.1 10.13.1
@polkadot/types UPDATED 10.6.1 10.13.1
@polkadot/types-augment UPDATED 10.6.1 10.13.1
@polkadot/types-codec UPDATED 10.6.1 10.13.1
@polkadot/types-create UPDATED 10.6.1 10.13.1
@polkadot/types-known UPDATED 10.6.1 10.13.1
@polkadot/types-support UPDATED 10.6.1 10.13.1
@polkadot/util UPDATED 12.1.2 12.6.2
@polkadot/util-crypto UPDATED 12.1.2 12.6.2
@polkadot/wasm-bridge UPDATED 7.1.2 7.3.2
@polkadot/wasm-crypto UPDATED 7.1.2 7.3.2
@polkadot/wasm-crypto-asmjs UPDATED 7.1.2 7.3.2
@polkadot/wasm-crypto-init UPDATED 7.1.2 7.3.2
@polkadot/wasm-crypto-wasm UPDATED 7.1.2 7.3.2
@polkadot/wasm-util UPDATED 7.1.2 7.3.2
@polkadot/x-bigint UPDATED 12.1.2 12.6.2
@polkadot/x-fetch UPDATED 12.1.2 12.6.2
@polkadot/x-global UPDATED 12.1.2 12.6.2
@polkadot/x-randomvalues UPDATED 12.1.2 12.6.2
@polkadot/x-textdecoder UPDATED 12.1.2 12.6.2
@polkadot/x-textencoder UPDATED 12.1.2 12.6.2
@polkadot/x-ws UPDATED 12.1.2 12.6.2
@scure/base UPDATED 1.1.1 1.1.6
@stablelib/aead ADDED - 1.0.1
@stablelib/binary ADDED - 1.0.1
@stablelib/bytes ADDED - 1.0.1
@stablelib/chacha ADDED - 1.0.1
@stablelib/chacha20poly1305 ADDED - 1.0.1
@stablelib/constant-time ADDED - 1.0.1
@stablelib/ed25519 ADDED - 1.0.3
@stablelib/hash ADDED - 1.0.1
@stablelib/hkdf ADDED - 1.0.1
@stablelib/hmac ADDED - 1.0.1
@stablelib/int ADDED - 1.0.1
@stablelib/keyagreement ADDED - 1.0.1
@stablelib/poly1305 ADDED - 1.0.1
@stablelib/random ADDED - 1.0.2
@stablelib/sha256 ADDED - 1.0.1
@stablelib/sha512 ADDED - 1.0.1
@stablelib/wipe ADDED - 1.0.1
@stablelib/x25519 ADDED - 1.0.3
@stellar/js-xdr ADDED - 3.1.1
@stellar/stellar-base ADDED - 11.0.1
@substrate/connect UPDATED 0.7.26 0.8.8
@substrate/connect-extension-protocol UPDATED 1.0.1 2.0.0
@substrate/connect-known-chains ADDED - 1.1.4
@substrate/light-client-extension-helpers ADDED - 0.0.4
@substrate/ss58-registry UPDATED 1.40.0 1.47.0
@talismn/connect-components ADDED - 1.1.8
@talismn/connect-ui ADDED - 1.1.3
@talismn/connect-wallets ADDED - 1.2.5
@tanstack/query-core ADDED - 5.31.0
@tanstack/react-query ADDED - 5.31.0
@testing-library/react ADDED - 13.4.0
@trysound/sax ADDED - 0.2.0
@types/big.js ADDED - 6.2.2
@types/bn.js UPDATED 5.1.1 5.1.5
@types/cssnano ADDED - 5.0.0
@types/react UPDATED 18.2.5 18.2.79
@types/react-dom ADDED - 18.2.25
@types/trusted-types ADDED - 2.0.7
@walletconnect/core ADDED - 2.12.2
@walletconnect/environment ADDED - 1.0.1
@walletconnect/events ADDED - 1.0.1
@walletconnect/heartbeat ADDED - 1.2.1
@walletconnect/jsonrpc-http-connection ADDED - 1.0.7
@walletconnect/jsonrpc-provider ADDED - 1.0.13
@walletconnect/jsonrpc-types ADDED - 1.0.3
@walletconnect/jsonrpc-utils ADDED - 1.0.8
@walletconnect/jsonrpc-ws-connection ADDED - 1.0.14
@walletconnect/keyvaluestorage ADDED - 1.1.1
@walletconnect/logger ADDED - 2.1.2
@walletconnect/modal ADDED - 2.6.2
@walletconnect/modal-core ADDED - 2.6.2
@walletconnect/modal-ui ADDED - 2.6.2
@walletconnect/relay-api ADDED - 1.0.10
@walletconnect/relay-auth ADDED - 1.0.4
@walletconnect/safe-json ADDED - 1.0.2
@walletconnect/sign-client ADDED - 2.12.2
@walletconnect/time ADDED - 1.0.2
@walletconnect/types ADDED - 2.12.2
@walletconnect/universal-provider ADDED - 2.12.2
@walletconnect/utils ADDED - 2.12.2
@walletconnect/window-getters ADDED - 1.0.1
@walletconnect/window-metadata ADDED - 1.0.1
acorn UPDATED 8.8.2 8.11.3
ansi-escapes UPDATED 6.2.0 6.2.1
atomic-sleep ADDED - 1.0.0
axios ADDED - 1.6.8
base32.js ADDED - 0.1.0
base64-js ADDED - 1.5.1
big.js ADDED - 6.2.1
bignumber.js ADDED - 9.1.2
binary-extensions ADDED - 2.3.0
boolbase ADDED - 1.0.0
buffer ADDED - 6.0.3
caniuse-api ADDED - 3.0.0
caniuse-lite UPDATED 1.0.30001482 1.0.30001612
chokidar ADDED - 3.6.0
citty ADDED - 0.1.6
clipboardy ADDED - 4.0.0
colord ADDED - 2.9.3
concat-with-sourcemaps ADDED - 1.1.0
confbox ADDED - 0.1.7
consola ADDED - 3.2.3
cookie-es ADDED - 1.1.0
cross-fetch ADDED - 3.1.8
crossws ADDED - 0.2.4
css-declaration-sorter ADDED - 6.4.1
css-select ADDED - 4.3.0
css-tree ADDED - 1.1.3
css-what ADDED - 6.1.0
cssesc ADDED - 3.0.0
cssnano ADDED - 5.1.15
cssnano-preset-default ADDED - 5.2.14
cssnano-utils ADDED - 3.1.0
csso ADDED - 4.2.0
decamelize ADDED - 1.2.0
decode-uri-component ADDED - 0.2.2
defu ADDED - 6.1.4
destr ADDED - 2.0.3
detect-browser ADDED - 5.3.0
detect-libc ADDED - 1.0.3
dijkstrajs ADDED - 1.0.3
dom-serializer ADDED - 1.4.1
domelementtype ADDED - 2.3.0
domhandler ADDED - 4.3.1
domutils ADDED - 2.8.0
duplexify ADDED - 4.1.3
electron-to-chromium UPDATED 1.4.382 1.4.745
encode-utf8 ADDED - 1.0.3
end-of-stream ADDED - 1.4.4
esbuild-plugin-polyfill-node ADDED - 0.3.0
events ADDED - 3.3.0
eventsource ADDED - 2.0.2
fast-redact ADDED - 3.5.0
filter-obj ADDED - 1.1.0
follow-redirects ADDED - 1.15.6
fs-extra ADDED - 10.1.0
function-bind UPDATED 1.1.1 1.1.2
generic-names ADDED - 4.0.0
get-port-please ADDED - 3.1.2
h3 ADDED - 1.11.1
hasown ADDED - 2.0.2
hey-listen ADDED - 1.0.8
http-shutdown ADDED - 1.2.2
husky UPDATED 8.0.3 9.0.11
icss-replace-symbols ADDED - 1.1.0
icss-utils ADDED - 5.1.0
idb-keyval ADDED - 6.2.1
ieee754 ADDED - 1.2.1
import-cwd ADDED - 3.0.0
import-from ADDED - 3.0.0
import-meta-resolve ADDED - 3.1.1
iron-webcrypto ADDED - 1.1.1
is-binary-path ADDED - 2.1.0
is-core-module UPDATED 2.12.0 2.13.1
is-docker ADDED - 3.0.0
is-inside-container ADDED - 1.0.0
is-wsl ADDED - 3.1.0
is64bit ADDED - 2.0.0
isomorphic-unfetch ADDED - 3.1.0
jiti ADDED - 1.21.0
jsonfile ADDED - 6.1.0
keyvaluestorage-interface ADDED - 1.0.0
lint-staged UPDATED 15.2.0 15.2.2
listhen ADDED - 1.7.2
listr2 UPDATED 8.0.0 8.0.1
lit ADDED - 2.8.0
lit-element ADDED - 3.3.3
lit-html ADDED - 2.8.0
loader-utils ADDED - 3.2.1
lodash.camelcase ADDED - 4.3.0
lodash.isequal ADDED - 4.5.0
lodash.memoize ADDED - 4.1.2
lodash.uniq ADDED - 4.5.0
lru-cache UPDATED 10.0.1 10.2.0
magic-string REMOVED 0.25.9 -
mdn-data ADDED - 2.0.14
mime ADDED - 3.0.0
mlly ADDED - 1.6.1
mock-socket UPDATED 9.2.1 9.3.1
motion ADDED - 10.16.2
mri ADDED - 1.2.0
multiformats ADDED - 9.9.0
nanoid UPDATED 3.3.6 3.3.7
napi-wasm ADDED - 1.1.0
nock UPDATED 13.3.1 13.5.4
node-addon-api ADDED - 7.1.0
node-fetch UPDATED 3.3.1 3.3.2
node-fetch-native ADDED - 1.6.4
node-forge ADDED - 1.3.1
node-gyp-build UPDATED 4.6.0 4.8.0
node-releases UPDATED 2.0.10 2.0.14
normalize-url ADDED - 6.1.0
npm-run-path UPDATED 5.1.0 5.3.0
nth-check ADDED - 2.1.1
ofetch ADDED - 1.3.4
ohash ADDED - 1.1.3
on-exit-leak-free ADDED - 0.2.0
p-finally ADDED - 1.0.0
p-queue ADDED - 6.6.2
p-timeout ADDED - 3.2.0
pathe ADDED - 1.1.2
pify ADDED - 5.0.0
pino ADDED - 7.11.0
pino-abstract-transport ADDED - 0.5.0
pino-std-serializers ADDED - 4.0.0
pkg-types ADDED - 1.1.0
pngjs ADDED - 5.0.0
postcss UPDATED 8.4.23 8.4.38
postcss-calc ADDED - 8.2.4
postcss-colormin ADDED - 5.3.1
postcss-convert-values ADDED - 5.1.3
postcss-discard-comments ADDED - 5.1.2
postcss-discard-duplicates ADDED - 5.1.0
postcss-discard-empty ADDED - 5.1.1
postcss-discard-overridden ADDED - 5.1.0
postcss-load-config ADDED - 3.1.4
postcss-merge-longhand ADDED - 5.1.7
postcss-merge-rules ADDED - 5.1.4
postcss-minify-font-values ADDED - 5.1.0
postcss-minify-gradients ADDED - 5.1.1
postcss-minify-params ADDED - 5.1.4
postcss-minify-selectors ADDED - 5.2.1
postcss-modules ADDED - 6.0.0
postcss-modules-extract-imports ADDED - 3.1.0
postcss-modules-local-by-default ADDED - 4.0.5
postcss-modules-scope ADDED - 3.2.0
postcss-modules-values ADDED - 4.0.0
postcss-normalize-charset ADDED - 5.1.0
postcss-normalize-display-values ADDED - 5.1.0
postcss-normalize-positions ADDED - 5.1.1
postcss-normalize-repeat-style ADDED - 5.1.1
postcss-normalize-string ADDED - 5.1.0
postcss-normalize-timing-functions ADDED - 5.1.0
postcss-normalize-unicode ADDED - 5.1.1
postcss-normalize-url ADDED - 5.1.0
postcss-normalize-whitespace ADDED - 5.1.1
postcss-ordered-values ADDED - 5.1.3
postcss-reduce-initial ADDED - 5.1.2
postcss-reduce-transforms ADDED - 5.1.0
postcss-selector-parser ADDED - 6.0.16
postcss-svgo ADDED - 5.1.0
postcss-unique-selectors ADDED - 5.1.1
postcss-value-parser ADDED - 4.2.0
process-warning ADDED - 1.0.0
promise.series ADDED - 0.2.0
proxy-compare ADDED - 2.5.1
proxy-from-env ADDED - 1.1.0
qrcode ADDED - 1.5.3
query-string ADDED - 7.1.3
quick-format-unescaped ADDED - 4.0.4
radix3 ADDED - 1.1.2
randombytes ADDED - 2.1.0
react ADDED - 18.2.0
react-daisyui ADDED - 5.0.0
react-dom ADDED - 18.2.0
react-native-compat ADDED - 1.0.0
readdirp ADDED - 3.6.0
real-require ADDED - 0.1.0
require-main-filename ADDED - 2.0.0
reserved-words ADDED - 0.1.2
rfdc UPDATED 1.3.0 1.3.1
rollup-plugin-inject REMOVED 3.0.2 -
rollup-plugin-node-polyfills REMOVED 0.2.1 -
rollup-plugin-postcss ADDED - 4.0.2
rollup-plugin-postcss-modules ADDED - 2.1.1
rollup-plugin-styles ADDED - 4.0.0
safe-identifier ADDED - 0.4.2
safe-stable-stringify ADDED - 2.4.3
scale-ts ADDED - 1.6.0
scheduler ADDED - 0.23.0
sha.js ADDED - 2.4.11
smoldot UPDATED 1.0.4 2.0.22
sodium-native ADDED - 4.1.1
sonic-boom ADDED - 2.8.0
source-map-js UPDATED 1.0.2 1.2.0
sourcemap-codec REMOVED 1.4.8 -
split-on-first ADDED - 1.1.0
split2 ADDED - 4.2.0
stable ADDED - 0.1.8
std-env ADDED - 3.7.0
stellar-base ADDED - 11.0.1
stellar-sdk ADDED - 11.3.0
stream-shift ADDED - 1.0.3
strict-uri-encode ADDED - 2.0.0
string-hash ADDED - 1.1.3
string-width UPDATED 7.0.0 7.1.0
style-inject ADDED - 0.3.0
stylehacks ADDED - 5.1.1
svgo ADDED - 2.8.0
system-architecture ADDED - 0.1.0
thread-stream ADDED - 0.15.2
toml ADDED - 3.0.0
tslib UPDATED 2.5.0 2.6.2
type-fest DOWNGRADED 3.13.1 0.21.3
ufo ADDED - 1.5.3
uint8arrays ADDED - 3.1.1
uncrypto ADDED - 0.1.3
unenv ADDED - 1.9.0
unfetch ADDED - 4.2.0
universalify UPDATED 0.2.0 2.0.1
unstorage ADDED - 1.10.2
untun ADDED - 0.1.3
update-browserslist-db UPDATED 1.0.11 1.0.13
uqr ADDED - 0.1.2
urijs ADDED - 1.19.11
use-sync-external-store ADDED - 1.2.0
valtio ADDED - 1.11.2
which-module ADDED - 2.0.1
ws UPDATED 8.13.0 8.16.0

Copy link

netlify bot commented Apr 25, 2024

Deploy Preview for pendulum-pay ready!

Name Link
🔨 Latest commit 6538ed6
🔍 Latest deploy log https://app.netlify.com/sites/pendulum-pay/deploys/66339f9111763c0008b21b00
😎 Deploy Preview https://deploy-preview-22--pendulum-pay.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member Author

@ebma ebma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall 👍

// enable CORS - Cross Origin Resource Sharing
app.use(cors());

const allowedOrigins = ['http://localhost:5173', 'https://pendulum-pay.netlify.app'];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this if it's not used? Might cause confusions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's. I intended to leave it for production but it is probably unnecessary for the prototype.

signer-service/src/api/routes/v1/stats.route.js Outdated Show resolved Hide resolved
signer-service/src/api/utils/APIError.js Outdated Show resolved Hide resolved
Comment on lines 15 to 16
const FUNDING_PUBLIC_KEY = process.env.FUNDING_PUBLIC_KEY;
const FUNDING_SECRET = process.env.FUNDING_SECRET;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Do we really need two separate variables here if the public key can simply be derived from the secret?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I didn't think about this. Let me make a small refactor so only secret is needed.

exports.createStellarTransaction = async (req, res, next) => {
try {
let { signature, sequence } = await buildCreationStellarTx(FUNDING_SECRET, req.body.accountId, req.body.maxTime);
return res.json({ signature, sequence, success: true, public: FUNDING_PUBLIC_KEY });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: success: true is redundant if we never return success: false. In case something fails we just return 500 anyways.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, and we are not checking for success on the UI, so I will just remove the field.

@gianfra-t gianfra-t merged commit 72771eb into offramp-prototype-staging May 2, 2024
4 checks passed
@ebma ebma deleted the 20-phase-3-of-offramp-prototype branch May 2, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Phase 3 of Offramp prototype Pendulum -> Spacewalk -> Stellar Mykobo
2 participants