diff --git a/packages/libs/sdk/spec/recordings/solana-client-prepareSmartTransaction_3623416322/recording.har b/packages/libs/sdk/spec/recordings/solana-client-prepareSmartTransaction_3623416322/recording.har new file mode 100644 index 00000000..bb71195b --- /dev/null +++ b/packages/libs/sdk/spec/recordings/solana-client-prepareSmartTransaction_3623416322/recording.har @@ -0,0 +1,384 @@ +{ + "log": { + "_recordingName": "solana-client-prepareSmartTransaction", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "d29a8a03e7650c1d4c9f0dd702fa1079", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 90, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "*/*" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "90" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip,deflate" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "alien-lingering-fire.solana-mainnet.quiknode.pro" + } + ], + "headersSize": 355, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"method\":\"qn_estimatePriorityFees\",\"params\":{\"last_n_blocks\":100},\"id\":1,\"jsonrpc\":\"2.0\"}" + }, + "queryString": [], + "url": "https://alien-lingering-fire.solana-mainnet.quiknode.pro" + }, + "response": { + "bodySize": 713, + "content": { + "mimeType": "application/json", + "size": 713, + "text": "{\"jsonrpc\":\"2.0\",\"result\":{\"context\":{\"slot\":254923002},\"per_compute_unit\":{\"extreme\":1842896,\"high\":250050,\"low\":28315,\"medium\":77957,\"percentiles\":{\"10\":1580,\"100\":8121677495,\"15\":2935,\"20\":7021,\"25\":10714,\"30\":15000,\"35\":20000,\"40\":28315,\"45\":40000,\"5\":721,\"50\":50003,\"55\":71428,\"60\":77957,\"65\":105160,\"70\":150000,\"75\":210526,\"80\":250050,\"85\":493403,\"90\":779577,\"95\":1842896}},\"per_transaction\":{\"extreme\":3295320,\"high\":500000,\"low\":49216,\"medium\":110000,\"percentiles\":{\"10\":700,\"100\":8121677495,\"15\":3182,\"20\":10000,\"25\":15189,\"30\":23004,\"35\":35400,\"40\":49216,\"45\":67500,\"5\":0,\"50\":83683,\"55\":100000,\"60\":110000,\"65\":150000,\"70\":200000,\"75\":250000,\"80\":500000,\"85\":762300,\"90\":1021245,\"95\":3295320}}},\"id\":1}" + }, + "cookies": [], + "headers": [ + { + "name": "access-control-allow-credentials", + "value": "true" + }, + { + "name": "access-control-allow-headers", + "value": "Content-Type,Authorization,User-Agent,solana-client" + }, + { + "name": "access-control-allow-methods", + "value": "GET, POST, OPTIONS" + }, + { + "name": "access-control-allow-origin", + "value": "" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "vary", + "value": "Accept-Encoding" + }, + { + "name": "x-host-id", + "value": "bdc3c6b0fcc2f18f" + }, + { + "name": "x-node-id", + "value": "solana_solana-mainnet_jfk" + }, + { + "name": "date", + "value": "Mon, 18 Mar 2024 11:50:58 GMT" + }, + { + "name": "content-length", + "value": "713" + }, + { + "name": "connection", + "value": "close" + } + ], + "headersSize": 405, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-03-18T11:50:57.611Z", + "time": 694, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 694 + } + }, + { + "_id": "acbd44d2b59f8bb85098f4a9278b5d64", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 103, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "solana-client", + "value": "js/0.0.0-development" + }, + { + "_fromType": "array", + "name": "accept", + "value": "*/*" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "103" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip,deflate" + }, + { + "name": "host", + "value": "alien-lingering-fire.solana-mainnet.quiknode.pro" + } + ], + "headersSize": 374, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"method\":\"getLatestBlockhash\",\"jsonrpc\":\"2.0\",\"params\":[],\"id\":\"e6aa9c8c-0dd5-4e9a-a5af-78a7461c5c74\"}" + }, + "queryString": [], + "url": "https://alien-lingering-fire.solana-mainnet.quiknode.pro" + }, + "response": { + "bodySize": 226, + "content": { + "mimeType": "application/json", + "size": 226, + "text": "{\"jsonrpc\":\"2.0\",\"result\":{\"context\":{\"apiVersion\":\"1.17.25\",\"slot\":254922957},\"value\":{\"blockhash\":\"2acCVCzy5dPndawWVvTYDoHWqoe4dXo1srhWQ4W5btnb\",\"lastValidBlockHeight\":235430258}},\"id\":\"e6aa9c8c-0dd5-4e9a-a5af-78a7461c5c74\"}" + }, + "cookies": [], + "headers": [ + { + "name": "access-control-allow-credentials", + "value": "true" + }, + { + "name": "access-control-allow-headers", + "value": "Content-Type,Authorization,User-Agent,solana-client" + }, + { + "name": "access-control-allow-methods", + "value": "GET, POST, OPTIONS" + }, + { + "name": "access-control-allow-origin", + "value": "" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "vary", + "value": "Accept-Encoding" + }, + { + "name": "x-host-id", + "value": "a92bc58d2be2e5b8" + }, + { + "name": "x-node-id", + "value": "solana_solana-mainnet_jfk" + }, + { + "name": "date", + "value": "Mon, 18 Mar 2024 11:50:58 GMT" + }, + { + "name": "content-length", + "value": "226" + } + ], + "headersSize": 386, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-03-18T11:50:58.316Z", + "time": 490, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 490 + } + }, + { + "_id": "cbce735a79b1ee99963508106a2c04fc", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 432, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "solana-client", + "value": "js/0.0.0-development" + }, + { + "_fromType": "array", + "name": "accept", + "value": "*/*" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "432" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip,deflate" + }, + { + "name": "host", + "value": "alien-lingering-fire.solana-mainnet.quiknode.pro" + } + ], + "headersSize": 374, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"method\":\"simulateTransaction\",\"jsonrpc\":\"2.0\",\"params\":[\"AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQABAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwZGb+UhFzL/7K26csOb57yM5bvF9xJrLEObOkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIBAAkDhTABAAAAAAABAAkDhTABAAAAAAAA\",{\"replaceRecentBlockhash\":true,\"sigVerify\":false,\"encoding\":\"base64\"}],\"id\":\"678acd71-b6f1-4894-a147-62305566965f\"}" + }, + "queryString": [], + "url": "https://alien-lingering-fire.solana-mainnet.quiknode.pro" + }, + "response": { + "bodySize": 221, + "content": { + "mimeType": "application/json", + "size": 221, + "text": "{\"jsonrpc\":\"2.0\",\"result\":{\"context\":{\"apiVersion\":\"1.17.24\",\"slot\":254923084},\"value\":{\"accounts\":null,\"err\":\"AccountNotFound\",\"logs\":[],\"returnData\":null,\"unitsConsumed\":0}},\"id\":\"678acd71-b6f1-4894-a147-62305566965f\"}\n" + }, + "cookies": [], + "headers": [ + { + "name": "access-control-allow-credentials", + "value": "true" + }, + { + "name": "access-control-allow-headers", + "value": "Content-Type,Authorization,User-Agent,solana-client" + }, + { + "name": "access-control-allow-methods", + "value": "GET, POST, OPTIONS" + }, + { + "name": "access-control-allow-origin", + "value": "" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "vary", + "value": "Accept-Encoding" + }, + { + "name": "x-host-id", + "value": "221ac2bcbd1ac759" + }, + { + "name": "x-node-id", + "value": "solana_solana-mainnet_jfk" + }, + { + "name": "date", + "value": "Mon, 18 Mar 2024 11:51:55 GMT" + }, + { + "name": "content-length", + "value": "221" + } + ], + "headersSize": 386, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-03-18T11:51:54.745Z", + "time": 691, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 691 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/libs/sdk/spec/recordings/solana-client-sendSmartTransaction_2450286823/recording.har b/packages/libs/sdk/spec/recordings/solana-client-sendSmartTransaction_2450286823/recording.har index 121bdc11..d932575e 100644 --- a/packages/libs/sdk/spec/recordings/solana-client-sendSmartTransaction_2450286823/recording.har +++ b/packages/libs/sdk/spec/recordings/solana-client-sendSmartTransaction_2450286823/recording.har @@ -8,11 +8,11 @@ }, "entries": [ { - "_id": "9fe398be7487c66224555bd974d9708b", + "_id": "acbd44d2b59f8bb85098f4a9278b5d64", "_order": 0, "cache": {}, "request": { - "bodySize": 89, + "bodySize": 103, "cookies": [], "headers": [ { @@ -20,6 +20,11 @@ "name": "content-type", "value": "application/json" }, + { + "_fromType": "array", + "name": "solana-client", + "value": "js/0.0.0-development" + }, { "_fromType": "array", "name": "accept", @@ -28,7 +33,7 @@ { "_fromType": "array", "name": "content-length", - "value": "89" + "value": "103" }, { "_fromType": "array", @@ -40,33 +45,28 @@ "name": "accept-encoding", "value": "gzip,deflate" }, - { - "_fromType": "array", - "name": "connection", - "value": "close" - }, { "name": "host", "value": "alien-lingering-fire.solana-mainnet.quiknode.pro" } ], - "headersSize": 355, + "headersSize": 374, "httpVersion": "HTTP/1.1", "method": "POST", "postData": { "mimeType": "application/json", "params": [], - "text": "{\"method\":\"qn_estimatePriorityFees\",\"params\":{\"last_n_blocks\":10},\"id\":1,\"jsonrpc\":\"2.0\"}" + "text": "{\"method\":\"getLatestBlockhash\",\"jsonrpc\":\"2.0\",\"params\":[],\"id\":\"743e324e-863f-42c9-8e37-64d4f7bd053b\"}" }, "queryString": [], "url": "https://alien-lingering-fire.solana-mainnet.quiknode.pro" }, "response": { - "bodySize": 720, + "bodySize": 225, "content": { "mimeType": "application/json", - "size": 720, - "text": "{\"jsonrpc\":\"2.0\",\"result\":{\"context\":{\"slot\":254810651},\"per_compute_unit\":{\"extreme\":1396328,\"high\":269696,\"low\":35714,\"medium\":100000,\"percentiles\":{\"10\":875,\"100\":231251300,\"15\":1505,\"20\":2193,\"25\":9545,\"30\":19759,\"35\":24687,\"40\":35714,\"45\":53287,\"5\":647,\"50\":71428,\"55\":100000,\"60\":100000,\"65\":138172,\"70\":168104,\"75\":214288,\"80\":269696,\"85\":432355,\"90\":688327,\"95\":1396328}},\"per_transaction\":{\"extreme\":3174711,\"high\":500000,\"low\":100000,\"medium\":154040,\"percentiles\":{\"10\":3333,\"100\":231251300,\"15\":16000,\"20\":25623,\"25\":46691,\"30\":71428,\"35\":86838,\"40\":100000,\"45\":100000,\"5\":736,\"50\":100000,\"55\":140000,\"60\":154040,\"65\":211012,\"70\":269483,\"75\":351550,\"80\":500000,\"85\":826943,\"90\":1053319,\"95\":3174711}}},\"id\":1}" + "size": 225, + "text": "{\"jsonrpc\":\"2.0\",\"result\":{\"context\":{\"apiVersion\":\"1.17.25\",\"slot\":254810612},\"value\":{\"blockhash\":\"81JmjjAtNSg7bFFigtrr19AUYArC9Pa2dKyCkYcZ1hX\",\"lastValidBlockHeight\":235321655}},\"id\":\"743e324e-863f-42c9-8e37-64d4f7bd053b\"}" }, "cookies": [], "headers": [ @@ -96,7 +96,7 @@ }, { "name": "x-host-id", - "value": "bdc3c6b0fcc2f18f" + "value": "a92bc58d2be2e5b8" }, { "name": "x-node-id", @@ -108,21 +108,17 @@ }, { "name": "content-length", - "value": "720" - }, - { - "name": "connection", - "value": "close" + "value": "225" } ], - "headersSize": 405, + "headersSize": 386, "httpVersion": "HTTP/1.1", "redirectURL": "", "status": 200, "statusText": "OK" }, - "startedDateTime": "2024-03-17T22:49:02.479Z", - "time": 520, + "startedDateTime": "2024-03-17T22:49:03.014Z", + "time": 416, "timings": { "blocked": -1, "connect": -1, @@ -130,15 +126,15 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 520 + "wait": 416 } }, { - "_id": "acbd44d2b59f8bb85098f4a9278b5d64", + "_id": "d29a8a03e7650c1d4c9f0dd702fa1079", "_order": 0, "cache": {}, "request": { - "bodySize": 103, + "bodySize": 90, "cookies": [], "headers": [ { @@ -146,11 +142,6 @@ "name": "content-type", "value": "application/json" }, - { - "_fromType": "array", - "name": "solana-client", - "value": "js/0.0.0-development" - }, { "_fromType": "array", "name": "accept", @@ -159,7 +150,7 @@ { "_fromType": "array", "name": "content-length", - "value": "103" + "value": "90" }, { "_fromType": "array", @@ -171,28 +162,33 @@ "name": "accept-encoding", "value": "gzip,deflate" }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, { "name": "host", "value": "alien-lingering-fire.solana-mainnet.quiknode.pro" } ], - "headersSize": 374, + "headersSize": 355, "httpVersion": "HTTP/1.1", "method": "POST", "postData": { "mimeType": "application/json", "params": [], - "text": "{\"method\":\"getLatestBlockhash\",\"jsonrpc\":\"2.0\",\"params\":[],\"id\":\"743e324e-863f-42c9-8e37-64d4f7bd053b\"}" + "text": "{\"method\":\"qn_estimatePriorityFees\",\"params\":{\"last_n_blocks\":100},\"id\":1,\"jsonrpc\":\"2.0\"}" }, "queryString": [], "url": "https://alien-lingering-fire.solana-mainnet.quiknode.pro" }, "response": { - "bodySize": 225, + "bodySize": 713, "content": { "mimeType": "application/json", - "size": 225, - "text": "{\"jsonrpc\":\"2.0\",\"result\":{\"context\":{\"apiVersion\":\"1.17.25\",\"slot\":254810612},\"value\":{\"blockhash\":\"81JmjjAtNSg7bFFigtrr19AUYArC9Pa2dKyCkYcZ1hX\",\"lastValidBlockHeight\":235321655}},\"id\":\"743e324e-863f-42c9-8e37-64d4f7bd053b\"}" + "size": 713, + "text": "{\"jsonrpc\":\"2.0\",\"result\":{\"context\":{\"slot\":254922416},\"per_compute_unit\":{\"extreme\":2158180,\"high\":250000,\"low\":20430,\"medium\":71428,\"percentiles\":{\"10\":1127,\"100\":8333333333,\"15\":2162,\"20\":4579,\"25\":9868,\"30\":10714,\"35\":15000,\"40\":20430,\"45\":30000,\"5\":666,\"50\":46691,\"55\":56000,\"60\":71428,\"65\":101146,\"70\":142857,\"75\":200000,\"80\":250000,\"85\":433208,\"90\":714286,\"95\":2158180}},\"per_transaction\":{\"extreme\":5000000,\"high\":433208,\"low\":50000,\"medium\":140000,\"percentiles\":{\"10\":1388,\"100\":8333333333,\"15\":5003,\"20\":10714,\"25\":19302,\"30\":25546,\"35\":40000,\"40\":50000,\"45\":71428,\"5\":1,\"50\":95010,\"55\":101773,\"60\":140000,\"65\":165411,\"70\":222222,\"75\":345382,\"80\":433208,\"85\":620015,\"90\":1021861,\"95\":5000000}}},\"id\":1}" }, "cookies": [], "headers": [ @@ -222,7 +218,7 @@ }, { "name": "x-host-id", - "value": "a92bc58d2be2e5b8" + "value": "bdc3c6b0fcc2f18f" }, { "name": "x-node-id", @@ -230,21 +226,25 @@ }, { "name": "date", - "value": "Sun, 17 Mar 2024 22:49:03 GMT" + "value": "Mon, 18 Mar 2024 11:46:52 GMT" }, { "name": "content-length", - "value": "225" + "value": "713" + }, + { + "name": "connection", + "value": "close" } ], - "headersSize": 386, + "headersSize": 405, "httpVersion": "HTTP/1.1", "redirectURL": "", "status": 200, "statusText": "OK" }, - "startedDateTime": "2024-03-17T22:49:03.014Z", - "time": 416, + "startedDateTime": "2024-03-18T11:46:52.103Z", + "time": 794, "timings": { "blocked": -1, "connect": -1, @@ -252,15 +252,15 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 416 + "wait": 794 } }, { - "_id": "d40204c9d7fa8c75b674051536586596", + "_id": "68f63970f5f951a23dc69856a0693356", "_order": 0, "cache": {}, "request": { - "bodySize": 428, + "bodySize": 432, "cookies": [], "headers": [ { @@ -281,7 +281,7 @@ { "_fromType": "array", "name": "content-length", - "value": "428" + "value": "432" }, { "_fromType": "array", @@ -304,7 +304,7 @@ "postData": { "mimeType": "application/json", "params": [], - "text": "{\"method\":\"simulateTransaction\",\"jsonrpc\":\"2.0\",\"params\":[\"AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQABAoQRxzJRFnXCoe6MBldnTlUf1q55/eUmCQ4F8R2+2mMoAwZGb+UhFzL/7K26csOb57yM5bvF9xJrLEObOkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIBAAUCwFwVAAEACQOghgEAAAAAAAA=\",{\"replaceRecentBlockhash\":true,\"sigVerify\":false,\"encoding\":\"base64\"}],\"id\":\"143a48fb-65e9-4f38-bce2-59989bf0ffdb\"}" + "text": "{\"method\":\"simulateTransaction\",\"jsonrpc\":\"2.0\",\"params\":[\"AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQABAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwZGb+UhFzL/7K26csOb57yM5bvF9xJrLEObOkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIBAAkDBBcBAAAAAAABAAkDBBcBAAAAAAAA\",{\"replaceRecentBlockhash\":true,\"sigVerify\":false,\"encoding\":\"base64\"}],\"id\":\"ed52f27a-d869-4d9e-8b23-f4de1c265760\"}" }, "queryString": [], "url": "https://alien-lingering-fire.solana-mainnet.quiknode.pro" @@ -314,7 +314,7 @@ "content": { "mimeType": "application/json", "size": 221, - "text": "{\"jsonrpc\":\"2.0\",\"result\":{\"context\":{\"apiVersion\":\"1.17.24\",\"slot\":254810875},\"value\":{\"accounts\":null,\"err\":\"AccountNotFound\",\"logs\":[],\"returnData\":null,\"unitsConsumed\":0}},\"id\":\"143a48fb-65e9-4f38-bce2-59989bf0ffdb\"}\n" + "text": "{\"jsonrpc\":\"2.0\",\"result\":{\"context\":{\"apiVersion\":\"1.17.26\",\"slot\":254922385},\"value\":{\"accounts\":null,\"err\":\"AccountNotFound\",\"logs\":[],\"returnData\":null,\"unitsConsumed\":0}},\"id\":\"ed52f27a-d869-4d9e-8b23-f4de1c265760\"}\n" }, "cookies": [], "headers": [ @@ -344,7 +344,7 @@ }, { "name": "x-host-id", - "value": "7df076da70980964" + "value": "c934868888f346eb" }, { "name": "x-node-id", @@ -352,7 +352,7 @@ }, { "name": "date", - "value": "Sun, 17 Mar 2024 22:50:51 GMT" + "value": "Mon, 18 Mar 2024 11:46:53 GMT" }, { "name": "content-length", @@ -365,8 +365,8 @@ "status": 200, "statusText": "OK" }, - "startedDateTime": "2024-03-17T22:50:50.384Z", - "time": 457, + "startedDateTime": "2024-03-18T11:46:53.328Z", + "time": 488, "timings": { "blocked": -1, "connect": -1, @@ -374,15 +374,15 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 457 + "wait": 488 } }, { - "_id": "9ab017fa768bd6818f7e168be8f93067", + "_id": "f9be7571431f5766900ea4c5eed30d0f", "_order": 0, "cache": {}, "request": { - "bodySize": 400, + "bodySize": 385, "cookies": [], "headers": [ { @@ -403,7 +403,7 @@ { "_fromType": "array", "name": "content-length", - "value": "400" + "value": "385" }, { "_fromType": "array", @@ -426,17 +426,17 @@ "postData": { "mimeType": "application/json", "params": [], - "text": "{\"method\":\"sendTransaction\",\"jsonrpc\":\"2.0\",\"params\":[\"AR+O2oVw/dL/ScU6fkVGNhwzD5895HOiamWuPv7YZVw1dpPbGhJhPt/1QfJCrzua0C2TkVkHTPkP8wTS3mxgqg8BAAEChBHHMlEWdcKh7owGV2dOVR/Wrnn95SYJDgXxHb7aYygDBkZv5SEXMv/srbpyw5vnvIzlu8X3EmssQ5s6QAAAAAHLaYBE/pnlByh2qLtexxJv4xuqEN/9aSFyVZcWLYn+AQEACQOghgEAAAAAAA==\",{\"encoding\":\"base64\",\"maxRetries\":0,\"skipPreflight\":true}],\"id\":\"7070c252-e2fd-45a1-82a0-73c3c2dead4d\"}" + "text": "{\"method\":\"sendTransaction\",\"jsonrpc\":\"2.0\",\"params\":[\"AduSSFWCowDxfELbBpmhfWTGny16JMwmTurwnRVS/Z7QwBdVKAMXhg84cxxHks8yJh03PW9/X4TEOhHGH/7GiwEBAAEChBHHMlEWdcKh7owGV2dOVR/Wrnn95SYJDgXxHb7aYygDBkZv5SEXMv/srbpyw5vnvIzlu8X3EmssQ5s6QAAAAAHLaYBE/pnlByh2qLtexxJv4xuqEN/9aSFyVZcWLYn+AQEACQMEFwEAAAAAAA==\",{\"encoding\":\"base64\",\"skipPreflight\":true}],\"id\":\"128e0f1d-eaa6-4039-b4b7-4b6a674af25a\"}" }, "queryString": [], "url": "https://alien-lingering-fire.solana-mainnet.quiknode.pro" }, "response": { - "bodySize": 161, + "bodySize": 162, "content": { "mimeType": "application/json", - "size": 161, - "text": "{\"jsonrpc\":\"2.0\",\"result\":\"dbW8AT3NwaUxEwM9VND16EJeeD8ecusCm3rD8GgVYZdrnFd1WzSydTQDMdzLLYcPJ1nhUFpGwtsZRjAyNruowmp\",\"id\":\"7070c252-e2fd-45a1-82a0-73c3c2dead4d\"}\n" + "size": 162, + "text": "{\"jsonrpc\":\"2.0\",\"result\":\"5PckAvNaSkW2fgWpk2tkeAz8finKFceTqCbJn319yUep8MxBCkFhPdbS4N5TJYbWf6rc5JxZ1uwE3TL3cvj1Skgx\",\"id\":\"128e0f1d-eaa6-4039-b4b7-4b6a674af25a\"}\n" }, "cookies": [], "headers": [ @@ -466,7 +466,7 @@ }, { "name": "x-host-id", - "value": "b7ab2b610219cdc4" + "value": "567d68f1d2c02130" }, { "name": "x-node-id", @@ -474,11 +474,11 @@ }, { "name": "date", - "value": "Sun, 17 Mar 2024 22:50:51 GMT" + "value": "Mon, 18 Mar 2024 11:46:53 GMT" }, { "name": "content-length", - "value": "161" + "value": "162" } ], "headersSize": 386, @@ -487,8 +487,8 @@ "status": 200, "statusText": "OK" }, - "startedDateTime": "2024-03-17T22:50:50.857Z", - "time": 133, + "startedDateTime": "2024-03-18T11:46:53.827Z", + "time": 134, "timings": { "blocked": -1, "connect": -1, @@ -496,7 +496,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 133 + "wait": 134 } } ], diff --git a/packages/libs/sdk/spec/solana/solanaClient.test.ts b/packages/libs/sdk/spec/solana/solanaClient.test.ts index 89e0fa92..d69cc14e 100644 --- a/packages/libs/sdk/spec/solana/solanaClient.test.ts +++ b/packages/libs/sdk/spec/solana/solanaClient.test.ts @@ -36,9 +36,47 @@ describe('solana client', () => { await expect( solana.sendSmartTransaction(transaction, keyPair, feeLevel) ).resolves.toMatchInlineSnapshot( - `"dbW8AT3NwaUxEwM9VND16EJeeD8ecusCm3rD8GgVYZdrnFd1WzSydTQDMdzLLYcPJ1nhUFpGwtsZRjAyNruowmp"` + `"5PckAvNaSkW2fgWpk2tkeAz8finKFceTqCbJn319yUep8MxBCkFhPdbS4N5TJYbWf6rc5JxZ1uwE3TL3cvj1Skgx"` ); } ); }); + it('should call solana prepareSmartTransaction', async () => { + await withPolly( + { + recordingName: 'solana-client-prepareSmartTransaction', + recordIfMissing: true, + }, + async () => { + const transaction = new Transaction(); + const feeLevel = 'medium'; + await expect(solana.prepareSmartTransaction(transaction, feeLevel)) + .resolves.toMatchInlineSnapshot(` + Object { + "feePayer": null, + "instructions": Array [ + Object { + "data": Array [ + 3, + 133, + 48, + 1, + 0, + 0, + 0, + 0, + 0, + ], + "keys": Array [], + "programId": "ComputeBudget111111111111111111111111111111", + }, + ], + "nonceInfo": null, + "recentBlockhash": "2acCVCzy5dPndawWVvTYDoHWqoe4dXo1srhWQ4W5btnb", + "signers": Array [], + } + `); + } + ); + }); }); diff --git a/packages/libs/sdk/src/solana/solana.ts b/packages/libs/sdk/src/solana/solana.ts index 617d5119..b29f42a8 100644 --- a/packages/libs/sdk/src/solana/solana.ts +++ b/packages/libs/sdk/src/solana/solana.ts @@ -8,6 +8,7 @@ import { PublicKey, TransactionMessage, VersionedTransaction, + SendOptions, } from '@solana/web3.js'; import { type EstimatePriorityFeesParams, @@ -26,9 +27,40 @@ export class Solana { this.connection = new Connection(endpointUrl); } + /** + * Sends a transaction with a dynamically generated priority fee based on the current network + * conditions and compute units needed by the transaction. + */ async sendSmartTransaction( transaction: Transaction, keyPair: Keypair, + feeLevel: PriorityFeeLevels = 'medium', + sendTransactionOptions?: SendOptions + ) { + const smartTransaction = await this.prepareSmartTransaction( + transaction, + feeLevel + ); + transaction.feePayer = keyPair.publicKey; + smartTransaction.sign(keyPair); + + const hash = await this.connection.sendRawTransaction( + transaction.serialize(), + { skipPreflight: true, ...sendTransactionOptions } + ); + + return hash; + } + + /** + * Prepares a transaction to be sent with a dynamically generated priority fee based + * on the current network conditions. It adds a `setComputeUnitPrice` instruction to the transaction + * and simulates the transaction to estimate the number of compute units it will consume. + * The returned transaction still needs to be signed and sent to the network. + */ + async prepareSmartTransaction( + transaction: Transaction, + payerKey: Keypair, // Needed for the simulation to avoid "invalid transaction: Transaction failed to sanitize accounts offsets correctly" feeLevel: PriorityFeeLevels = 'medium' ) { const computeUnitPriceInstruction = @@ -43,7 +75,8 @@ export class Solana { this.getSimulationUnits( this.connection, allInstructions, - keyPair.publicKey + payerKey, + feeLevel ), this.connection.getLatestBlockhash(), ]); @@ -53,20 +86,23 @@ export class Solana { units = Math.ceil(units * 1.05); // margin of error transaction.add(ComputeBudgetProgram.setComputeUnitLimit({ units })); } - transaction.feePayer = keyPair.publicKey; transaction.recentBlockhash = recentBlockhash.blockhash; - transaction.sign(keyPair); - - const hash = await this.connection.sendRawTransaction( - transaction.serialize(), - { skipPreflight: true, maxRetries: 0 } - ); + return transaction; + } - return hash; + private async createDynamicPriorityFeeInstruction( + feeType: PriorityFeeLevels = 'medium' + ) { + const { result } = await this.fetchEstimatePriorityFees({}); + const priorityFee = result.per_compute_unit[feeType]; + const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: priorityFee, + }); + return priorityFeeInstruction; } private async fetchEstimatePriorityFees({ - last_n_blocks = 10, + last_n_blocks = 100, account = undefined, }: EstimatePriorityFeesParams): Promise { const params: { last_n_blocks?: number; account?: string } = {}; @@ -105,32 +141,21 @@ export class Solana { return data; } - private async createDynamicPriorityFeeInstruction( - feeType: PriorityFeeLevels = 'medium' - ) { - const { result } = await this.fetchEstimatePriorityFees({}); - const priorityFee = result.per_compute_unit[feeType]; - const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: priorityFee, - }); - return priorityFeeInstruction; - } - private async getSimulationUnits( connection: Connection, instructions: TransactionInstruction[], - payer: PublicKey + payerKey: Keypair, + feeLevel: PriorityFeeLevels ): Promise { - const testInstructions = [ - ComputeBudgetProgram.setComputeUnitLimit({ units: 1_400_000 }), - ...instructions, - ]; + const computeUnitPriceInstruction = + await this.createDynamicPriorityFeeInstruction(feeLevel); + const testInstructions = [...instructions, computeUnitPriceInstruction]; const testVersionedTxn = new VersionedTransaction( new TransactionMessage({ instructions: testInstructions, - payerKey: payer, - recentBlockhash: PublicKey.default.toString(), + payerKey: payerKey.publicKey, + recentBlockhash: PublicKey.default.toString(), // just a placeholder }).compileToV0Message() );